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


Python plistlib.readPlistFromString方法代码示例

本文整理汇总了Python中plistlib.readPlistFromString方法的典型用法代码示例。如果您正苦于以下问题:Python plistlib.readPlistFromString方法的具体用法?Python plistlib.readPlistFromString怎么用?Python plistlib.readPlistFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plistlib的用法示例。


在下文中一共展示了plistlib.readPlistFromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _GetCSPSearchPathForPath

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def _GetCSPSearchPathForPath(path):
  """Returns list of search nodes for a given path.

  Args:
    path: One of '/Search' or '/Search/Contacts' only.
  Returns:
    nodes: list of search nodes for given path.
  Raises:
    DSException: Unable to retrieve search nodes in path.
  """

  command = [_DSCL, '-plist', path, '-read', '/', 'CSPSearchPath']
  (stdout, stderr, unused_returncode) = gmacpyutil.RunProcess(command)
  result = plistlib.readPlistFromString(stdout)
  if 'dsAttrTypeStandard:CSPSearchPath' in result:
    search_nodes = result['dsAttrTypeStandard:CSPSearchPath']
    return search_nodes
  else:
    raise DSException('Unable to retrieve search nodes: %s' % stderr) 
开发者ID:google,项目名称:macops,代码行数:21,代码来源:ds.py

示例2: masterlist

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def masterlist():
	master_db = []
	master_dict = {}
	master_data = connection.getURL(SHOWS)
	master_tree = plistlib.readPlistFromString(master_data)
	for master_item in master_tree:
		master_name = common.smart_utf8(master_item['name'])
		tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
		if tvdb_name not in master_dict.keys():
			master_dict[tvdb_name] = master_item['show-id']
		else:
			master_dict[tvdb_name] = master_dict[tvdb_name] + ',' + master_item['show-id']
	for master_name in master_dict:
		season_url = master_dict[master_name]
		master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:18,代码来源:adultswim.py

示例3: _parse_osx_xml_plist_data

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def _parse_osx_xml_plist_data(data):
    import plistlib
    import re
    dict_values = {}
    try:  # Python 2
        xml_data = plistlib.readPlistFromString(data)
    except AttributeError:  # Python => 3.4
        # pylint: disable=no-member
        xml_data = plistlib.loads(data)

    items_dict = xml_data[0]['_items'][0]
    r = re.compile(r'.*UUID.*')  # Find to example "platform_UUID" key
    uuid_keys = list(filter(r.match, list(items_dict.keys())))
    if uuid_keys:
        dict_values['UUID'] = items_dict[uuid_keys[0]]
    if not uuid_keys:
        r = re.compile(r'.*serial.*number.*')  # Find to example "serial_number" key
        serialnumber_keys = list(filter(r.match, list(items_dict.keys())))
        if serialnumber_keys:
            dict_values['serialnumber'] = items_dict[serialnumber_keys[0]]
    return dict_values 
开发者ID:CastagnaIT,项目名称:plugin.video.netflix,代码行数:23,代码来源:uuid_device.py

示例4: extract_provision_data

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def extract_provision_data(self):
        extract_info = self.get_filename_from_ipa('Provision')
        zip_obj = extract_info['zip_obj']
        provision_filename = extract_info['filename']

        data = {}
        if provision_filename == '':
            self.errors.append('embedded.mobileprovision file not found in IPA')
        else:
            content = zip_obj.read(provision_filename)
            match = ParseIPA.provision_xml_rx.search(content)
            if (match is not None):
                provision_xml_content = match.group()
                data = plistlib.readPlistFromString(provision_xml_content)
            else:
                self.errors.append('unable to parse embedded.mobileprovision file')

        self.provision_data = data
    # end extract_provision_data 
开发者ID:NetEaseGame,项目名称:iOS-private-api-checker,代码行数:21,代码来源:checkipa.py

示例5: gatewayCommandReceived

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def gatewayCommandReceived(self, command):
        """
        Process a command via gateway.Runner

        @param command: GatewayAMPCommand
        @returns: a deferred returning a dict
        """
        command = readPlistFromString(command)
        output = cStringIO.StringIO()
        from calendarserver.tools.gateway import Runner
        runner = Runner(
            self.store,
            [command], output=output
        )

        try:
            yield runner.run()
            result = output.getvalue()
            output.close()
        except Exception as e:
            error = {"Error": str(e)}
            result = writePlistToString(error)

        output.close()
        returnValue(dict(result=result)) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:27,代码来源:agent.py

示例6: checkreceipt

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def checkreceipt(packageid):
    try:
        cmd = ['/usr/sbin/pkgutil', '--pkg-info-plist', packageid]
        proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        output = proc.communicate()
        receiptout = output[0]
        if receiptout:
            plist = plistlib.readPlistFromString(receiptout)
            version = plist['pkg-version']
        else:
            version = '0.0.0.0.0'
        return version
    except Exception:
        version = '0.0.0.0.0'
        return version 
开发者ID:macadmins,项目名称:installapplications,代码行数:18,代码来源:installapplications.py

示例7: recvPlist

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def recvPlist(self):
        payload = self.recv_raw()
        if not payload:
            return
        bplist_header = "bplist00"
        xml_header = "<?xml"
        if PY3:
            bplist_header = b"bplist00"
            xml_header = b"<?xml"
        if payload.startswith(bplist_header):
            if PY3:
                return plistlib.readPlistFromString(payload)
            else:
                from pymobiledevice.util.bplist import BPlistReader
                return BPlistReader(payload).parse()
        elif payload.startswith(xml_header):
            #HAX lockdown HardwarePlatform with null bytes
            payload = sub('[^\w<>\/ \-_0-9\"\'\\=\.\?\!\+]+','', payload.decode('utf-8')).encode('utf-8')
            return plistlib.readPlistFromString(payload)
        else:
            raise Exception("recvPlist invalid data : %s" % payload[:100].encode("hex")) 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:23,代码来源:plist_service.py

示例8: fact

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def fact():
    """Returns the CPU L3 cache"""

    result = "None"

    try:
        proc = subprocess.Popen(
            ["/usr/sbin/system_profiler", "SPHardwareDataType", "-xml"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        stdout, _ = proc.communicate()
    except (IOError, OSError):
        stdout = None

    if stdout:
        d = plistlib.readPlistFromString(stdout.strip())
        result = d[0]["_items"][0]["l3_cache"]

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:22,代码来源:cpu_l3_cache.py

示例9: fact

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def fact():
    """Returns the boot drive medium"""
    result = "None"

    try:
        proc = subprocess.Popen(
            ["/usr/sbin/diskutil", "info", "-plist", "/"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        stdout, _ = proc.communicate()
    except (IOError, OSError):
        stdout = None

    if stdout:
        d = plistlib.readPlistFromString(stdout.strip())
        if d.get("CoreStorageCompositeDisk", False):
            result = "fusion"
        elif d.get("RAIDMaster", False):
            result = "raid"
        else:
            result = "ssd" if d.get("SolidState", False) else "rotational"

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:26,代码来源:drive_medium.py

示例10: fact

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def fact():
    """Return the Find My Mac status"""
    result = False
    try:
        proc = subprocess.Popen(
            ["/usr/sbin/nvram", "-x", "-p", "status"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        stdout, _ = proc.communicate()
    except (IOError, OSError):
        stdout = ""

    if stdout:
        if plistlib.readPlistFromString(stdout).get("fmm-mobileme-token-FMM", None):
            result = True
        return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:19,代码来源:fmm_status.py

示例11: fact

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def fact():
    """Returns the number of CPU cores"""

    result = "None"

    try:
        proc = subprocess.Popen(
            ["/usr/sbin/system_profiler", "SPHardwareDataType", "-xml"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        stdout, _ = proc.communicate()
    except (IOError, OSError):
        stdout = None

    if stdout:
        d = plistlib.readPlistFromString(stdout.strip())
        result = d[0]["_items"][0]["number_processors"]

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:22,代码来源:cpu_cores.py

示例12: _DictFromSubprocess

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def _DictFromSubprocess(command, stdin=None):
  """returns a dict based upon a subprocess call with a -plist argument.

  Args:
    command: the command to be executed as a list
    stdin: any standard input required.
  Returns:
    dict: dictionary from command output
  Raises:
    MacDiskError: Error running command
    MacDiskError: Error creating plist from standard output
  """

  task = {}

  if stdin:
    (task["stdout"],
     task["stderr"],
     task["returncode"]) = gmacpyutil.RunProcess(command, stdin)
  else:
    (task["stdout"],
     task["stderr"],
     task["returncode"]) = gmacpyutil.RunProcess(command)

  if task["returncode"] is not 0:
    raise MacDiskError("Error running command: %s, stderr: %s" %
                       (command, task["stderr"]))
  else:
    try:
      return plistlib.readPlistFromString(task["stdout"])
    except xml.parsers.expat.ExpatError:
      raise MacDiskError("Error creating plist from output: %s" %
                         task["stdout"]) 
开发者ID:google,项目名称:macops,代码行数:35,代码来源:macdisk.py

示例13: rules_from

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def rules_from(data):  # type: (str) -> list(str)
    log.debug("rules_from({!r})".format(data))
    dict_ = plistlib.readPlistFromString(data)
    log.debug(dict_)
    return dict_.get('rule', []) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:7,代码来源:security.py

示例14: test_string

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def test_string(self):
        pl = self._create()
        data = plistlib.writePlistToString(pl)
        pl2 = plistlib.readPlistFromString(data)
        self.assertEqual(dict(pl), dict(pl2))
        data2 = plistlib.writePlistToString(pl2)
        self.assertEqual(data, data2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_plistlib.py

示例15: test_indentation_array

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import readPlistFromString [as 别名]
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_plistlib.py


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