Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
bundlebuilder.BundleBuilder Class Reference
Inheritance diagram for bundlebuilder.BundleBuilder:
Inheritance graph
[legend]
Collaboration diagram for bundlebuilder.BundleBuilder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setup
def build
def preProcess
def postProcess
def message
def report

Public Attributes

 bundlepath

Static Public Attributes

 name = None
tuple plist
string type = "BNDL"
 creator = None
 bundle_id = None
list resources = []
list files = []
list libs = []
string builddir = "build"
int symlink = 0
int verbosity = 1
string destroot = ""

Private Member Functions

def _addMetaFiles
def _copyFiles

Detailed Description

BundleBuilder is a barebones class for assembling bundles. It
knows nothing about executables or icons, it only copies files
and creates the PkgInfo and Info.plist files.

Definition at line 68 of file bundlebuilder.py.


Member Function Documentation

Definition at line 175 of file bundlebuilder.py.

00175 
00176     def _addMetaFiles(self):
00177         contents = pathjoin(self.bundlepath, "Contents")
00178         makedirs(contents)
00179         #
00180         # Write Contents/PkgInfo
00181         assert len(self.type) == len(self.creator) == 4, \
00182                 "type and creator must be 4-byte strings."
00183         pkginfo = pathjoin(contents, "PkgInfo")
00184         f = open(pkginfo, "wb")
00185         f.write((self.type + self.creator).encode('latin1'))
00186         f.close()
00187         #
00188         # Write Contents/Info.plist
00189         infoplist = pathjoin(contents, "Info.plist")
00190         self.plist.write(infoplist)

Here is the call graph for this function:

Here is the caller graph for this function:

def bundlebuilder.BundleBuilder._copyFiles (   self) [private]

Definition at line 191 of file bundlebuilder.py.

00191 
00192     def _copyFiles(self):
00193         files = self.files[:]
00194         for path in self.resources:
00195             files.append((path, pathjoin("Contents", "Resources",
00196                 os.path.basename(path))))
00197         for path in self.libs:
00198             files.append((path, pathjoin("Contents", "Frameworks",
00199                 os.path.basename(path))))
00200         if self.symlink:
00201             self.message("Making symbolic links", 1)
00202             msg = "Making symlink from"
00203         else:
00204             self.message("Copying files", 1)
00205             msg = "Copying"
00206         files.sort()
00207         for src, dst in files:
00208             if os.path.isdir(src):
00209                 self.message("%s %s/ to %s/" % (msg, src, dst), 2)
00210             else:
00211                 self.message("%s %s to %s" % (msg, src, dst), 2)
00212             dst = pathjoin(self.bundlepath, dst)
00213             if self.symlink:
00214                 symlink(src, dst, mkdirs=1)
00215             else:
00216                 copy(src, dst, mkdirs=1)

Here is the call graph for this function:

Here is the caller graph for this function:

Build the bundle.

Definition at line 140 of file bundlebuilder.py.

00140 
00141     def build(self):
00142         """Build the bundle."""
00143         builddir = self.builddir
00144         if builddir and not os.path.exists(builddir):
00145             os.mkdir(builddir)
00146         self.message("Building %s" % repr(self.bundlepath), 1)
00147         if os.path.exists(self.bundlepath):
00148             shutil.rmtree(self.bundlepath)
00149         if os.path.exists(self.bundlepath + '~'):
00150             shutil.rmtree(self.bundlepath + '~')
00151         bp = self.bundlepath
00152 
00153         # Create the app bundle in a temporary location and then
00154         # rename the completed bundle. This way the Finder will
00155         # never see an incomplete bundle (where it might pick up
00156         # and cache the wrong meta data)
00157         self.bundlepath = bp + '~'
00158         try:
00159             os.mkdir(self.bundlepath)
00160             self.preProcess()
00161             self._copyFiles()
00162             self._addMetaFiles()
00163             self.postProcess()
00164             os.rename(self.bundlepath, bp)
00165         finally:
00166             self.bundlepath = bp
00167         self.message("Done.", 1)

Here is the call graph for this function:

def bundlebuilder.BundleBuilder.message (   self,
  msg,
  level = 0 
)

Definition at line 217 of file bundlebuilder.py.

00217 
00218     def message(self, msg, level=0):
00219         if level <= self.verbosity:
00220             indent = ""
00221             if level > 1:
00222                 indent = (level - 1) * "  "
00223             sys.stderr.write(indent + msg + "\n")

Here is the caller graph for this function:

Hook for subclasses.

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 171 of file bundlebuilder.py.

00171 
00172     def postProcess(self):
00173         """Hook for subclasses."""
00174         pass

Here is the caller graph for this function:

Hook for subclasses.

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 168 of file bundlebuilder.py.

00168 
00169     def preProcess(self):
00170         """Hook for subclasses."""
        pass

Here is the caller graph for this function:

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 224 of file bundlebuilder.py.

00224 
00225     def report(self):
00226         # XXX something decent
00227         pass
00228 

Here is the caller graph for this function:

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 117 of file bundlebuilder.py.

00117 
00118     def setup(self):
00119         # XXX rethink self.name munging, this is brittle.
00120         self.name, ext = os.path.splitext(self.name)
00121         if not ext:
00122             ext = ".bundle"
00123         bundleextension = ext
00124         # misc (derived) attributes
00125         self.bundlepath = pathjoin(self.builddir, self.name + bundleextension)
00126 
00127         plist = self.plist
00128         plist.CFBundleName = self.name
00129         plist.CFBundlePackageType = self.type
00130         if self.creator is None:
00131             if hasattr(plist, "CFBundleSignature"):
00132                 self.creator = plist.CFBundleSignature
00133             else:
00134                 self.creator = "????"
00135         plist.CFBundleSignature = self.creator
00136         if self.bundle_id:
00137             plist.CFBundleIdentifier = self.bundle_id
00138         elif not hasattr(plist, "CFBundleIdentifier"):
00139             plist.CFBundleIdentifier = self.name


Member Data Documentation

Definition at line 105 of file bundlebuilder.py.

Definition at line 91 of file bundlebuilder.py.

Definition at line 124 of file bundlebuilder.py.

Definition at line 88 of file bundlebuilder.py.

Definition at line 115 of file bundlebuilder.py.

Definition at line 98 of file bundlebuilder.py.

Definition at line 102 of file bundlebuilder.py.

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 79 of file bundlebuilder.py.

Initial value:
Plist(CFBundleDevelopmentRegion = "English",
                  CFBundleInfoDictionaryVersion = "6.0")

Definition at line 82 of file bundlebuilder.py.

Definition at line 94 of file bundlebuilder.py.

Definition at line 109 of file bundlebuilder.py.

Reimplemented in bundlebuilder.AppBuilder.

Definition at line 86 of file bundlebuilder.py.

Definition at line 112 of file bundlebuilder.py.


The documentation for this class was generated from the following file: