當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。