本文整理汇总了Python中plistlib.readPlist方法的典型用法代码示例。如果您正苦于以下问题:Python plistlib.readPlist方法的具体用法?Python plistlib.readPlist怎么用?Python plistlib.readPlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plistlib
的用法示例。
在下文中一共展示了plistlib.readPlist方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mac_ver_xml
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _mac_ver_xml():
fn = '/System/Library/CoreServices/SystemVersion.plist'
if not os.path.exists(fn):
return None
try:
import plistlib
except ImportError:
return None
pl = plistlib.readPlist(fn)
release = pl['ProductVersion']
versioninfo=('', '', '')
machine = os.uname().machine
if machine in ('ppc', 'Power Macintosh'):
# for compatibility with the gestalt based code
machine = 'PowerPC'
return release,versioninfo,machine
示例2: items
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def items():
'''
Retrieve all profiles in full
CLI Example:
.. code-block:: bash
salt '*' profiles.items
'''
tmpdir = tempfile.mkdtemp('.profiles')
tmpfile = os.path.join(tmpdir, 'profiles.plist')
status = __salt__['cmd.retcode']('/usr/bin/profiles -P -o {}'.format(tmpfile))
if not status == 0:
raise salt.exceptions.CommandExecutionError(
'Failed to read profiles or write to temporary file'
)
profiles = plistlib.readPlist(tmpfile)
os.unlink(tmpfile)
os.rmdir(tmpdir)
return profiles
示例3: _mac_ver_xml
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _mac_ver_xml():
fn = '/System/Library/CoreServices/SystemVersion.plist'
if not os.path.exists(fn):
return None
try:
import plistlib
except ImportError:
return None
pl = plistlib.readPlist(fn)
release = pl['ProductVersion']
versioninfo=('', '', '')
machine = os.uname()[4]
if machine in ('ppc', 'Power Macintosh'):
# for compatibility with the gestalt based code
machine = 'PowerPC'
return release,versioninfo,machine
示例4: _macosx_vers
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _macosx_vers(_cache=[]):
if not _cache:
import platform
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
import plistlib
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.'))
return _cache[0]
示例5: getIdentifier
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def getIdentifier(pluginDir):
try:
pFile = Core.storage.join_path(
self.PLUGIN_DIR, pluginDir, 'Contents', 'Info.plist')
pl = plistlib.readPlist(pFile)
createStamp = datetime.datetime.fromtimestamp(
os.path.getmtime(pFile)).strftime('%Y-%m-%d %H:%M:%S')
return (pl['CFBundleIdentifier'], createStamp)
except Exception, e:
errMsg = str(e) + '\nfor something in directory: ' + \
Core.storage.join_path(self.PLUGIN_DIR, pluginDir)
errMsg = errMsg + '\nSkipping migration of directory'
Log.Error('Exception in Migrate/getIdentifier : ' + errMsg)
pass
# Main call
示例6: generate_item
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def generate_item(manifest_path):
print('processing: {}'.format(manifest_path))
try:
p = plistlib.readPlist(manifest_path)
result = {
'ManifestPath': manifest_path,
'PayloadType': p['pfm_domain'],
'PayloadDisplayName': p.get('pfm_title', None),
'PayloadDescription': p['pfm_description'],
'PayloadIOSMinVersion': p.get('pfm_ios_min', None),
'PayloadIOSMaxVersion': p.get('pfm_ios_max', None),
'PayloadMacOSMinVersion': p.get('pfm_macos_min', None),
'PayloadMacOSMaxVersion': p.get('pfm_macos_max', None),
'PayloadTvOSMinVersion': p.get('pfm_tvos_min', None),
'PayloadTvOSMaxVersion': p.get('pfm_tvos_max', None),
'PayloadSingleton': p.get('pfm_unique', False),
'PayloadSupervisionRequired': p.get('pfm_supervised', False),
}
except ValueError as e:
result = {'ManifestPath': manifest_path, 'error': True, 'errorMessage': e.message}
print('skipping: {}'.format(manifest_path))
pass
return result
示例7: _load_info_plist
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _load_info_plist(self):
"""Load workflow info from ``info.plist``."""
# info.plist should be in the directory above this one
self._info = plistlib.readPlist(self.workflowfile('info.plist'))
self._info_loaded = True
示例8: _load_info_plist
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _load_info_plist(self):
"""Load workflow info from ``info.plist``
"""
self._info = plistlib.readPlist(self._info_plist)
self._info_loaded = True
示例9: _macosx_vers
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def _macosx_vers(_cache=[]):
if not _cache:
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.'))
return _cache[0]
示例10: process_systemversion_plist
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def process_systemversion_plist(abs_file_path, export_file, md5, outfile):
print("About to process: " + abs_file_path)
abs_file_path_quotes = "'"+abs_file_path+"'"
#process with plistlib
plist_info = plistlib.readPlist(abs_file_path)
#set keys to extract from sytemversion.plist
key_name = "ProductVersion"
#pass plist to plist_parser_module
version = get_system_version(plist_info, abs_file_path, md5, export_file, outfile, key_name)
示例11: process_system_plists
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def process_system_plists(abs_file_path, export_file, md5, outfile, outfile_error):
print("About to process: " + abs_file_path)
abs_file_path_quotes = "'"+abs_file_path+"'"
#process with plistlib
plist_info = plistlib.readPlist(abs_file_path)
#write out file metadata
export_file.write("\n-------------------------------------------------------------------------------------------\n")
export_file.write("\n" + 'File Path: ' + "\t" + abs_file_path + "\n")
export_file.write('MD5: ' + "\t\t" + str(md5) + "\n\n")
#pass plist to plist_parser_module
plist_parser_module(plist_info, abs_file_path, md5, export_file, outfile)
示例12: test_io
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def test_io(self):
pl = self._create()
plistlib.writePlist(pl, test_support.TESTFN)
pl2 = plistlib.readPlist(test_support.TESTFN)
self.assertEqual(dict(pl), dict(pl2))
示例13: test_stringio
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def test_stringio(self):
from StringIO import StringIO
f = StringIO()
pl = self._create()
plistlib.writePlist(pl, f)
pl2 = plistlib.readPlist(StringIO(f.getvalue()))
self.assertEqual(dict(pl), dict(pl2))
示例14: test_cstringio
# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlist [as 别名]
def test_cstringio(self):
from cStringIO import StringIO
f = StringIO()
pl = self._create()
plistlib.writePlist(pl, f)
pl2 = plistlib.readPlist(StringIO(f.getvalue()))
self.assertEqual(dict(pl), dict(pl2))