当前位置: 首页>>代码示例>>Python>>正文


Python plistlib.readPlist方法代码示例

本文整理汇总了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 
开发者ID:war-and-code,项目名称:jawfish,代码行数:21,代码来源:platform.py

示例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 
开发者ID:mosen,项目名称:salt-osx,代码行数:27,代码来源:profile.py

示例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 
开发者ID:glmcdona,项目名称:meddle,代码行数:21,代码来源:platform.py

示例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] 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:18,代码来源:pkg_resources.py

示例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 
开发者ID:ukdtom,项目名称:WebTools.bundle,代码行数:18,代码来源:gitV3.py

示例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 
开发者ID:mosen,项目名称:profiledocs,代码行数:26,代码来源:pfm2index.py

示例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 
开发者ID:TKkk-iOSer,项目名称:wechat-alfred-workflow,代码行数:7,代码来源:workflow.py

示例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 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:9,代码来源:workflow.py

示例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] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:__init__.py

示例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) 
开发者ID:mantarayforensics,项目名称:mantaray,代码行数:14,代码来源:plist_processor.py

示例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) 
开发者ID:mantarayforensics,项目名称:mantaray,代码行数:16,代码来源:plist_processor.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_plistlib.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_plistlib.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_plistlib.py


注:本文中的plistlib.readPlist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。