def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate, platform='MacOS', copy=mergecopy, mergetree=mergetree, condition=skipscm, plist={}): kw = module.plist_template.infoPlistDict( plist.get('CFBundleExecutable', name), plist) app = os.path.join(destdir, kw['CFBundleName'] + extension) contents = os.path.join(app, 'Contents') resources = os.path.join(contents, 'Resources') platdir = os.path.join(contents, platform) dirs = [contents, resources, platdir] plist = plistlib.Plist() plist.update(kw) plistPath = os.path.join(contents, 'Info.plist') if os.path.exists(plistPath): if plist != plistlib.Plist.fromFile(plistPath): for d in dirs: shutil.rmtree(d, ignore_errors=True) for d in dirs: makedirs(d) plist.write(plistPath) srcmain = module.setup.main() destmain = os.path.join(platdir, kw['CFBundleExecutable']) open(os.path.join(contents, 'PkgInfo'), 'w').write( kw['CFBundlePackageType'] + kw['CFBundleSignature'] ) copy(srcmain, destmain) make_exec(destmain) mergetree( resource_filename(module.__name__, 'lib'), resources, condition=condition, copyfn=copy, ) return app, plist
def openFontPlistFile(psName, dirPath): # Find or create the plist file. This hold a Python dictionary in repr() form, # key: glyph name, value: outline point list # This is used to determine which glyphs are manually hinted, and which have changed since the last # hint pass. fontPlist = None filePath = None isNewPlistFile = 1 pPath1 = os.path.join(dirPath, psName + kFontPlistSuffix) if os.path.exists(pPath1): filePath = pPath1 else: # Crude approach to file length limitations. Since Adobe keeps face info in separate directories, I don't worry about name collisions. pPath2 = os.path.join(dirPath, psName[:-len(kFontPlistSuffix)] + kFontPlistSuffix) if os.path.exists(pPath2): filePath = pPath2 if not filePath: filePath = pPath1 else: try: fontPlist = plistlib.Plist.fromFile(filePath) isNewPlistFile = 0 except (IOError, OSError): raise ACFontError("\tError: font plist file exists, but coud not be read <%s>." % filePath) except: raise ACFontError("\tError: font plist file exists, but coud not be parsed <%s>." % filePath) if fontPlist == None: fontPlist = plistlib.Plist() if not fontPlist.has_key(kACIDKey): fontPlist[kACIDKey] = {} return fontPlist, filePath, isNewPlistFile
def create_pluginbundle(destdir, name, plist): module = bundletemplate kw = module.plist_template.infoPlistDict( plist.get('CFBundleExecutable', name), plist) plugin = os.path.join(destdir, kw['CFBundleName'] + '.plugin') contents = os.path.join(plugin, 'Contents') resources = os.path.join(contents, 'Resources') platdir = os.path.join(contents, 'MacOS') dirs = [contents, resources, platdir] plist = plistlib.Plist() plist.update(kw) plistPath = os.path.join(contents, 'Info.plist') if os.path.exists(plistPath): if plist != plistlib.Plist.fromFile(plistPath): for d in dirs: shutil.rmtree(d, ignore_errors=True) for d in dirs: makedirs(d) plist.write(plistPath) srcmain = module.setup.main_executable_path() destmain = os.path.join(platdir, kw['CFBundleExecutable']) open(os.path.join(contents, 'PkgInfo'), 'w').write(kw['CFBundlePackageType'] + kw['CFBundleSignature']) mergecopy(srcmain, destmain) make_exec(destmain) mergetree( resource_filename(module.__name__, 'lib'), resources, condition=skipscm, copyfn=mergecopy, ) return plugin, plist
def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate, platform='MacOS', copy=mergecopy, mergetree=mergetree, condition=skipscm, plist={}, arch=None, redirect_stdout=False): kw = module.plist_template.infoPlistDict( plist.get('CFBundleExecutable', name), plist) app = os.path.join(destdir, kw['CFBundleName'] + extension) if os.path.exists(app): # Remove any existing build artifacts to ensure that # we're getting a clean build shutil.rmtree(app) contents = os.path.join(app, 'Contents') resources = os.path.join(contents, 'Resources') platdir = os.path.join(contents, platform) dirs = [contents, resources, platdir] plist = plistlib.Plist() plist.update(kw) plistPath = os.path.join(contents, 'Info.plist') if os.path.exists(plistPath): if plist != plistlib.Plist.fromFile(plistPath): for d in dirs: shutil.rmtree(d, ignore_errors=True) for d in dirs: makedirs(d) plist.write(plistPath) srcmain = module.setup.main(arch=arch, redirect_asl=redirect_stdout) if sys.version_info[0] == 2 \ and isinstance(kw['CFBundleExecutable'], unicode): destmain = os.path.join(platdir, kw['CFBundleExecutable'].encode('utf-8')) else: destmain = os.path.join(platdir, kw['CFBundleExecutable']) with open(os.path.join(contents, 'PkgInfo'), 'w') as fp: fp.write(kw['CFBundlePackageType'] + kw['CFBundleSignature']) print("Copy %r -> %r" % (srcmain, destmain)) copy(srcmain, destmain) make_exec(destmain) mergetree( resource_filename(module.__name__, 'lib'), resources, condition=condition, copyfn=copy, ) return app, plist
def getSerialized(self): ''' Returns a string plist representing the command ''' plist = plistlib.Plist() plist['command'] = self.CMD_ID cmd_values = self.getData() plist.update(cmd_values) ret = plistlib.writePlistToString(plist) if isinstance(self, NetworkDetailCmd): pass #print ret return ret
def dump(self, pathOrFile): packages = [] for pkg in self._packages: packages.append(pkg.dump()) plistdata = { 'Version': self._version, 'Maintainer': self._maintainer, 'Description': self._description, 'Packages': packages } plist = plistlib.Plist(**plistdata) plist.write(pathOrFile)
def _writePlistInfo(self): """ Writes the Info.plist file in the Contests directory. """ pl = plistlib.Plist( CFBundleExecutable=self.executable, CFBundleGetInfoString='%s-1.0.0' % self.name, CFBundleIconFile=os.path.basename(self.icns), CFBundleIdentifier='com.%s' % self.name, CFBundlePackageType='APPL', CFBundleVersion='1.0.0', CFBundleShortVersionString='1.0.0', ) plistlib.writePlist(pl, os.path.join(self.contents_dir, 'Info.plist'))
def dump(self, pathOrFile): """Dump the contents of the database to an XML .plist file. The file can be passed as either a file object or a pathname. All data, including included databases, is dumped.""" packages = [] for pkg in self._packages: packages.append(pkg.dump()) plistdata = {'Version': self._version, 'Maintainer': self._maintainer, 'Description': self._description, 'Packages': packages} plist = plistlib.Plist(**plistdata) plist.write(pathOrFile)
def _create(self): pl = plistlib.Plist( aString="Doodah", aList=["A", "B", 12, 32.1, [1, 2, 3]], aFloat = 0.1, anInt = 728, aDict=plistlib.Dict( anotherString="<hello & hi there!>", aUnicodeValue=u'M\xe4ssig, Ma\xdf', aTrueValue=True, aFalseValue=False, ), someData = plistlib.Data("<binary gunk>"), someMoreData = plistlib.Data("<lots of binary gunk>" * 10), ) pl['anotherInt'] = 42 try: from xml.utils.iso8601 import parse import time except ImportError: pass else: pl['aDate'] = plistlib.Date(time.mktime(time.gmtime())) return pl
def write(dct, path): p = plistlib.Plist() p.update(dct) p.write(path)
def __init__(self): self._profile = plistlib.Plist() self.Set(PAYLOADKEYS_CONTENT, [])