本文整理汇总了Python中plistlib.Plist.fromFile方法的典型用法代码示例。如果您正苦于以下问题:Python Plist.fromFile方法的具体用法?Python Plist.fromFile怎么用?Python Plist.fromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plistlib.Plist
的用法示例。
在下文中一共展示了Plist.fromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def __init__(self, project_path=None):
if not os.path.isabs(project_path):
project_path = os.path.join(os.getcwd(), project_path)
self.project_path = project_path
self.root = None
if project_path and os.path.exists(project_path):
try:
doc = xml.dom.minidom.parse(project_path)
# Get the first app-bundle tag and ignore any others.
self.root = utils.node_get_element_by_tag_name(doc, "app-bundle")
except:
print "Could not load project %s:" % (project_path)
raise
# The directory the project file is in (as opposed to
# project_path which is the path including the filename).
self.project_dir, tail = os.path.split(project_path)
plist_path = self.get_plist_path()
try:
plist = Plist.fromFile(plist_path)
except EnvironmentError, e:
if e.errno == errno.ENOENT:
print "Info.plist file not found: " + plist_path
sys.exit(1)
else:
raise
示例2: py2app
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def py2app(self):
""" Generates PList settings and sets values for setuptools.setup() arg.
Sets:
- execute script
- require package
- plist file
- app icon.(not yet)
"""
from plistlib import Plist
self.setup_args['app'] = ['music_controller/__main__.py']
self.setup_args['setup_requires'].append('py2app')
plist = Plist.fromFile('osx/Info.plist')
plist.update ( dict(
CFBundleShortVersionString = version.__version__+':'+get_rev(),
NSHumanReadableCopyright = u"Copyright 2012 mei raka",
))
if not 'options' in self.setup_args:
self.setup_args['options'] = {}
if not 'py2app' in self.setup_args['options']:
self.setup_args['options']['py2app'] = {}
self.setup_args['options']['py2app'] = dict(
plist=plist
)
# add lang
'''
示例3: test_f_get_name
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def test_f_get_name(self):
try:
plist_path = self.goodproject.get_plist_path()
except KeyError:
self.fail("Goodproject didn't set the default prefix")
try:
plist = Plist.fromFile(plist_path)
name = plist.CFBundleExecutable
except IOError:
self.fail("Path problem " + plist_path)
pname = self.goodproject.get_name()
self.failUnlessEqual(pname, name, "Bad Name %s" % pname)
示例4: handle_about_dlog
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def handle_about_dlog(self):
global mufsim_version
if platform.system() == 'Darwin' and not mufsim_version:
if "MufSim.app/Contents/Resources" in os.getcwd():
from plistlib import Plist
plist = Plist.fromFile(os.path.join('..', 'Info.plist'))
mufsim_version = plist['CFBundleShortVersionString']
if mufsim_version is None:
mufsim_version = ""
showinfo(
"About MufSimulator",
"MufSimulator %s\nCopyright 2016\nRevar Desmera" % mufsim_version,
parent=self.root,
)
示例5: main
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def main(httpbase=HTTPBASE, upload=True):
plist = Plist.fromFile(os.path.join(PLISTDIR, plat+'.plist'))
print 'Querying package information'
spl = runsetup('--name --version --url --description').read().split('\n')[:-1]
name, version, url = spl[:3]
description = '\n'.join(spl[3:])
print 'Building dumb distribution for %s-%s' % (name, version)
runsetup('bdist_dumb').read()
hash = md5.md5()
fn = '%s-%s.%s.tar.gz' % (name, version, plat)
print 'Calculating MD5 hash for', fn
f = file(os.path.join('dist', fn), 'rb')
while 1:
s = f.read(1024)
if not s:
break
hash.update(s)
f.close()
hash = hash.hexdigest()
if upload:
print 'Uploading', fn
os.system(UPLOADCMD % os.path.join('dist', fn))
for pkg in plist.Packages:
if pkg.Name == name and pkg.Flavor == 'binary':
print 'Existing package metadata found'
break
else:
print 'Creating new package metadata'
pkg = {
'Flavor':'binary',
'Install-test':'\nimport %s\n\t\t\t' % (name,),
'Prerequisites':[],
}
plist.Packages.append(pkg)
pkg['Name'] = name
pkg['Version'] = version
pkg['MD5Sum'] = hash
pkg['Download-URL'] = httpbase + fn
if url:
pkg['Home-page'] = url
if description and not pkg.get('Description', None):
pkg['Description'] = '\n%s\n\t\t\t' % (description,)
print 'Writing out new plist'
plist.write(os.path.join(PLISTDIR, plat+'.plist'))
示例6: generate_plist
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def generate_plist(plist_file):
"""Read plist from file and set CFBundleVersion to HEAD commit hash"""
version = git('git', 'describe', '--abbrev=0', '--tags')
commit_hash = git('git', 'rev-parse', '--short', 'HEAD')
if version is None or commit_hash is None:
sys.exit(-1)
plist = Plist.fromFile(plist_file)
plist.update(dict(
CFBundleShortVersionString=version,
CFBundleVersion=commit_hash,
))
return plist
示例7: __init__
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def __init__(self, project):
self.project = project
self.project_dir = project.get_project_dir()
plist_path = self.project.get_plist_path()
self.plist = Plist.fromFile(plist_path)
# List of paths that should be recursively searched for
# binaries that are used to find library dependencies.
self.binary_paths = []
# Create the bundle in a temporary location first and move it
# to the final destination when done.
dest = project.get_meta().dest
self.bundle_path = os.path.join(dest, "." + project.get_name() + ".app")
示例8: __init__
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def __init__(self, testxml, path):
doc = xml.dom.minidom.parseString(testxml)
self.root = utils.node_get_element_by_tag_name(doc, "app-bundle")
assert self.root != None
dir, tail = os.path.split(path)
self.project_dir = os.path.join(os.getcwd(), dir)
self.project_path = os.path.join(self.project_dir, tail)
try:
plist_path = os.path.join(self.project_dir, "test.plist")
plist = Plist.fromFile(plist_path)
except EnvironmentError, e:
if e.errno == errno.ENOENT:
print "Info.plist file not found: " + plist_path
sys.exit(1)
else:
raise
示例9: make_app_bundle
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def make_app_bundle(self):
plist_path = os.path.join(
self.bundle_skeleton_dir, 'Contents', 'Info.plist')
app_name = 'Unknown'
plist = None
if os.path.exists(plist_path):
plist = Plist.fromFile(plist_path)
app_name = plist['CFBundleExecutable']
else:
print 'Warning: no Contents/Info.plist in .app skeleton'
self.bundle_app_dir = os.path.join(
self.bundle_output_dir, app_name + '.app')
self.bundle_contents_dir = os.path.join(
self.bundle_app_dir, 'Contents')
self.bundle_res_dir = os.path.join(
self.bundle_contents_dir, 'Resources')
self.bundle_macos_dir = os.path.join(self.bundle_contents_dir, 'MacOS')
# Create the .app tree, copying the skeleton
shutil.rmtree(self.bundle_app_dir, ignore_errors=True)
shutil.copytree(self.bundle_skeleton_dir, self.bundle_app_dir)
if not os.path.exists(self.bundle_contents_dir):
os.makedirs(self.bundle_contents_dir)
if not os.path.exists(self.bundle_res_dir):
os.makedirs(self.bundle_res_dir)
if not os.path.exists(self.bundle_macos_dir):
os.makedirs(self.bundle_macos_dir)
# Generate the PkgInfo
pkginfo_path = os.path.join(self.bundle_contents_dir, 'PkgInfo')
if not os.path.exists(pkginfo_path) and not plist is None:
fp = open(pkginfo_path, 'w')
fp.write(plist['CFBundlePackageType'])
fp.write(plist['CFBundleSignature'])
fp.close()
# Run solitary against the installation to collect files
files = ''
for file in self.bundle_from_build:
files = files + ' "%s"' % os.path.join(self.prefix, file)
run_shell('mono --debug ../../solitary/Solitary.exe '
'--mono-prefix="%s" --root="%s" --out="%s" %s' %
(self.prefix, self.prefix, self.bundle_res_dir, files))
self.configure_gtk()
self.configure_gdk_pixbuf()
示例10: make_app_bundle
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def make_app_bundle(self):
plist_path = os.path.join(self.bundle_skeleton_dir, "Contents", "Info.plist")
app_name = "Unknown"
plist = None
if os.path.exists(plist_path):
plist = Plist.fromFile(plist_path)
app_name = plist["CFBundleExecutable"]
else:
print "Warning: no Contents/Info.plist in .app skeleton"
self.bundle_app_dir = os.path.join(self.bundle_output_dir, app_name + ".app")
self.bundle_contents_dir = os.path.join(self.bundle_app_dir, "Contents")
self.bundle_res_dir = os.path.join(self.bundle_contents_dir, "Resources")
self.bundle_macos_dir = os.path.join(self.bundle_contents_dir, "MacOS")
# Create the .app tree, copying the skeleton
shutil.rmtree(self.bundle_app_dir, ignore_errors=True)
shutil.copytree(self.bundle_skeleton_dir, self.bundle_app_dir)
if not os.path.exists(self.bundle_contents_dir):
os.makedirs(self.bundle_contents_dir)
if not os.path.exists(self.bundle_res_dir):
os.makedirs(self.bundle_res_dir)
if not os.path.exists(self.bundle_macos_dir):
os.makedirs(self.bundle_macos_dir)
# Generate the PkgInfo
pkginfo_path = os.path.join(self.bundle_contents_dir, "PkgInfo")
if not os.path.exists(pkginfo_path) and not plist == None:
fp = open(pkginfo_path, "w")
fp.write(plist["CFBundlePackageType"])
fp.write(plist["CFBundleSignature"])
fp.close()
# Run solitary against the installation to collect files
files = ""
for file in self.bundle_from_build:
files = files + ' "%s"' % os.path.join(self.prefix, file)
run_shell(
"mono --debug ../../solitary/Solitary.exe "
'--mono-prefix="%s" --root="%s" --out="%s" %s' % (self.prefix, self.prefix, self.bundle_res_dir, files)
)
self.configure_gtk()
self.configure_gdk_pixbuf()
示例11: _get_macos_ver_info_from_plist
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def _get_macos_ver_info_from_plist(self):
"""Retrive Mac OS system information from
/System/Library/CoreServices/SystemVersion.plist
as suggested here:
http://tinyurl.com/9ssrn
"""
plist_path = "/System/Library/CoreServices/SystemVersion.plist"
if not exists(plist_path):
return
try:
from plistlib import Plist
except ImportError:
return
plist = Plist.fromFile(plist_path)
return {
"os_ver": plist["ProductVersion"],
"os_build": plist["ProductBuildVersion"],
"os_name": plist["ProductName"],
}
示例12: __init__
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def __init__(self, project):
self.project = project
self.project_dir = project.get_project_dir()
plist_path = self.project.get_plist_path()
self.plist = Plist.fromFile(plist_path)
# List of paths that should be recursively searched for
# binaries that are used to find library dependencies.
self.binaries_to_copy = []
self.copied_binaries = []
#List of frameworks moved into the bundle which need to be set
#up for private use.
self.frameworks = []
# Create the bundle in a temporary location first and move it
# to the final destination when done.
self.meta = project.get_meta()
self.bundle_path = os.path.join(self.meta.dest, "." + project.get_bundle_name() + ".app")
示例13: buildApp
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def buildApp(trunkDir, releaseDir, version="DEV", appName="Numenta Vision4 Demo"):
print "Building application..."
print "trunkDir: %s" % trunkDir
print "releaseDir: %s" % releaseDir
# Special incantation to import py2app checked in to svn
py2appdir = "external/darwin86/lib/python%s/site-packages-py2app" % \
pythonVersion
py2appdir = os.path.join(trunkDir, py2appdir)
import site
site.addsitedir(py2appdir)
# Make sure we get nupic and external packages from the right place.
sitePackagesDir = os.path.join(releaseDir, "lib/python%s/site-packages" %
pythonVersion)
sys.path.insert(0, sitePackagesDir)
visionDir = os.path.join(releaseDir, "share", "vision")
origDir = os.getcwd()
os.chdir(visionDir)
if os.path.exists("dist"):
print "Removing previous installation"
shutil.rmtree("dist")
src = os.path.join(sitePackagesDir, "PIL")
dest = os.path.join(sitePackagesDir, "Image")
if not os.path.exists(dest):
print "Linking %s to %s" % (dest, src)
os.symlink(src, dest)
from setuptools import setup
import py2app.recipes
# the matplotlib recipe adds a bad dependency on pytz.zoneinfo
del py2app.recipes.matplotlib
assert(len(sys.argv) == 1)
sys.argv.append("py2app")
from plistlib import Plist
licenseText = """
Copyright (C) 2009 Numenta Inc. All rights reserved.
This copy of the software is a development version
and is not authorized for any release or use outside of
the Numenta engineering team.
"""
licenseFile = os.path.join(visionDir, "LICENSE")
if os.path.exists(licenseFile):
licenseText = open(licenseFile).read()
# To appear properly in quicklook,
# license paragraph should be unwrapped.
# \n-><space>, but \n\n should remain unchanged
licenseText = licenseText.replace("\n\n", "XXX")
licenseText = licenseText.replace("\n", " ")
licenseText = licenseText.replace("XXX", "\n\n")
plistFile = os.path.join(visionDir, "Info.plist")
if os.path.exists(plistFile):
plist = Plist.fromFile(plistFile)
else:
print "File '%s' not found" % plistFile
plist = dict()
plist.update(dict(CFBundleVersion=version,
CFBundleShortVersionString=version,
CFBundleName=appName,
NSHumanReadableCopyright=licenseText))
print "Running setup..."
setup(
app=["RunDemo.py"],
setup_requires=["py2app"],
# data_files=['networks/nta4.xml.gz', 'data/nta4_test'], -- doesn't create the subdirs
options=dict(
py2app=dict(
includes=[],
packages=['nupic', # problem finding image files in site-packages.zip
'matplotlib', # problem finding data files in site-packages.zip
'curses', # seg fault in site-packages.zip
'opencv', # import error
'enthought',
'wx', # bus error when dragging files
],
plist=plist,
iconfile="demo.icns"
)
)
)
print "Done with base app creation"
app = os.path.join(visionDir, "dist", "%s.app" % appName)
appResources=os.path.join(app, "Contents/Resources")
#.........这里部分代码省略.........
示例14: print_error
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
import sys
from lib.util import print_error
from lib.version import ELECTRUM_VERSION as version
name = "Electrum-XVG"
mainscript = 'electrum-xvg'
if sys.version_info[:3] < (2, 6, 0):
print_error("Error: " + name + " requires Python version >= 2.6.0...")
sys.exit(1)
if sys.platform == 'darwin':
from plistlib import Plist
plist = Plist.fromFile('Info.plist')
plist.update(dict(CFBundleIconFile='electrum.icns'))
shutil.copy(mainscript, mainscript + '.py')
mainscript += '.py'
extra_options = dict(
setup_requires=['py2app'],
app=[mainscript],
options=dict(py2app=dict(argv_emulation=False,
includes=['PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4.QtWebKit', 'PyQt4.QtNetwork', 'sip'],
packages=['lib', 'gui', 'plugins'],
iconfile='electrum.icns',
plist=plist,
resources=["icons"])),
)
elif sys.platform == 'win32':
示例15: main
# 需要导入模块: from plistlib import Plist [as 别名]
# 或者: from plistlib.Plist import fromFile [as 别名]
def main():
if not sys.argv[1:]:
print HELP_TEXT
return
scripts = []
data_files = []
packages = []
args = []
plist = {}
iconfile = None
parsing_options = True
next_is_option = False
cmd_options = get_cmd_options()
is_make_setup = False
for fn in sys.argv[1:]:
if parsing_options:
if next_is_option:
args.append(fn)
next_is_option = False
continue
elif fn == '--make-setup':
is_make_setup = True
continue
elif fn.startswith('-'):
args.append(fn)
if fn in cmd_options:
next_is_option = True
continue
parsing_options = False
if not is_make_setup:
fn = os.path.abspath(fn)
if fn.endswith('.py'):
if scripts:
data_files.append(fn)
else:
scripts.append(fn)
elif os.path.basename(fn) == 'Info.plist':
plist = Plist.fromFile(fn)
elif fn.endswith('.icns') and not iconfile:
iconfile = os.path.abspath(fn)
elif os.path.isdir(fn):
sys.path.insert(0, [os.path.dirname(fn)])
try:
path = imp.find_module(os.path.basename(fn))[0]
except ImportError:
path = ''
del sys.path[0]
if os.path.realpath(path) == os.path.realpath(fn):
packages.append(os.path.basename(fn))
else:
data_files.append(fn)
else:
data_files.append(fn)
options = dict(
packages=packages,
plist=plist,
iconfile=iconfile,
argv_emulation=True,
)
for k,v in options.items():
if not v:
del options[k]
if is_make_setup:
make_setup(args, scripts, data_files, options)
else:
build(args, scripts, data_files, options)