本文整理汇总了Python中plistlib.Plist类的典型用法代码示例。如果您正苦于以下问题:Python Plist类的具体用法?Python Plist怎么用?Python Plist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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
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
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
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
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
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__
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__
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
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
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
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__
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: main
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)
示例14: main
def main(builder=None):
if builder is None:
builder = AppBuilder(verbosity=1)
shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa"
longopts = ("builddir=", "name=", "resource=", "file=", "executable=",
"mainprogram=", "creator=", "nib=", "plist=", "link",
"link-exec", "help", "verbose", "quiet", "argv", "standalone",
"exclude=", "include=", "package=", "strip", "iconfile=",
"lib=", "python=", "semi-standalone", "bundle-id=", "destroot=")
try:
options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
except getopt.error:
usage()
for opt, arg in options:
if opt in ('-b', '--builddir'):
builder.builddir = arg
elif opt in ('-n', '--name'):
builder.name = arg
elif opt in ('-r', '--resource'):
builder.resources.append(os.path.normpath(arg))
elif opt in ('-f', '--file'):
srcdst = arg.split(':')
if len(srcdst) != 2:
usage("-f or --file argument must be two paths, "
"separated by a colon")
builder.files.append(srcdst)
elif opt in ('-e', '--executable'):
builder.executable = arg
elif opt in ('-m', '--mainprogram'):
builder.mainprogram = arg
elif opt in ('-a', '--argv'):
builder.argv_emulation = 1
elif opt in ('-c', '--creator'):
builder.creator = arg
elif opt == '--bundle-id':
builder.bundle_id = arg
elif opt == '--iconfile':
builder.iconfile = arg
elif opt == "--lib":
builder.libs.append(os.path.normpath(arg))
elif opt == "--nib":
builder.nibname = arg
elif opt in ('-p', '--plist'):
builder.plist = Plist.fromFile(arg)
elif opt in ('-l', '--link'):
builder.symlink = 1
elif opt == '--link-exec':
builder.symlink_exec = 1
elif opt in ('-h', '--help'):
usage()
elif opt in ('-v', '--verbose'):
builder.verbosity += 1
elif opt in ('-q', '--quiet'):
builder.verbosity -= 1
elif opt == '--standalone':
builder.standalone = 1
elif opt == '--semi-standalone':
builder.semi_standalone = 1
elif opt == '--python':
builder.python = arg
elif opt in ('-x', '--exclude'):
builder.excludeModules.append(arg)
elif opt in ('-i', '--include'):
builder.includeModules.append(arg)
elif opt == '--package':
builder.includePackages.append(arg)
elif opt == '--strip':
builder.strip = 1
elif opt == '--destroot':
builder.destroot = arg
if len(args) != 1:
usage("Must specify one command ('build', 'report' or 'help')")
command = args[0]
if command == "build":
builder.setup()
builder.build()
elif command == "report":
builder.setup()
builder.report()
elif command == "help":
usage()
else:
usage("Unknown command '%s'" % command)
示例15: main
def main(builder=None):
if builder is None:
builder = AppBuilder(verbosity=1)
shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa"
longopts = (
"builddir=",
"name=",
"resource=",
"file=",
"executable=",
"mainprogram=",
"creator=",
"nib=",
"plist=",
"link",
"link-exec",
"help",
"verbose",
"quiet",
"argv",
"standalone",
"exclude=",
"include=",
"package=",
"strip",
"iconfile=",
"lib=",
"python=",
"semi-standalone",
"bundle-id=",
"destroot=no-zipimport",
)
try:
options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
except getopt.error:
usage()
for opt, arg in options:
if opt in ("-b", "--builddir"):
builder.builddir = arg
elif opt in ("-n", "--name"):
builder.name = arg
elif opt in ("-r", "--resource"):
builder.resources.append(os.path.normpath(arg))
elif opt in ("-f", "--file"):
srcdst = arg.split(":")
if len(srcdst) != 2:
usage("-f or --file argument must be two paths, separated by a colon")
builder.files.append(srcdst)
elif opt in ("-e", "--executable"):
builder.executable = arg
elif opt in ("-m", "--mainprogram"):
builder.mainprogram = arg
elif opt in ("-a", "--argv"):
builder.argv_emulation = 1
elif opt in ("-c", "--creator"):
builder.creator = arg
elif opt == "--bundle-id":
builder.bundle_id = arg
elif opt == "--iconfile":
builder.iconfile = arg
elif opt == "--lib":
builder.libs.append(os.path.normpath(arg))
elif opt == "--nib":
builder.nibname = arg
elif opt in ("-p", "--plist"):
builder.plist = Plist.fromFile(arg)
elif opt in ("-l", "--link"):
builder.symlink = 1
elif opt == "--link-exec":
builder.symlink_exec = 1
elif opt in ("-h", "--help"):
usage()
elif opt in ("-v", "--verbose"):
builder.verbosity += 1
elif opt in ("-q", "--quiet"):
builder.verbosity -= 1
elif opt == "--standalone":
builder.standalone = 1
elif opt == "--semi-standalone":
builder.semi_standalone = 1
elif opt == "--python":
builder.python = arg
elif opt in ("-x", "--exclude"):
builder.excludeModules.append(arg)
elif opt in ("-i", "--include"):
builder.includeModules.append(arg)
elif opt == "--package":
builder.includePackages.append(arg)
elif opt == "--strip":
builder.strip = 1
elif opt == "--destroot":
builder.destroot = arg
elif opt == "--no-zipimport":
builder.use_zipimport = False
if len(args) != 1:
usage("Must specify one command ('build', 'report' or 'help')")
command = args[0]
if command == "build":
#.........这里部分代码省略.........