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


Python plistlib.writePlistToString方法代码示例

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


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

示例1: _content_to_uuid

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def _content_to_uuid(payload):
    '''
    Generate a UUID based upon the payload content

    :param payload:
    :return:
    '''
    log.debug('Attempting to Hash {}'.format(payload))

    if six.PY3:
        str_payload = plistlib.dumps(payload)
    else:
        str_payload = plistlib.writePlistToString(payload)
    hashobj = hashlib.md5(str_payload)

    identifier = re.sub(
        b'([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})',
        b'\\1-\\2-\\3-\\4-\\5',
        binascii.hexlify(hashobj.digest()))

    return identifier.decode() 
开发者ID:mosen,项目名称:salt-osx,代码行数:23,代码来源:profile.py

示例2: test_loadServerConfig

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def test_loadServerConfig(self):
        """
        The Calendar Server host and port are loaded from the [server]
        section of the configuration file specified.
        """
        config = FilePath(self.mktemp())
        config.setContent(
            writePlistToString({"servers": {
                "PodA": {
                    "enabled": True,
                    "uri": 'https://127.0.0.3:8432/',
                    "stats": {"enabled": False},
                },
            }})
        )
        sim = LoadSimulator.fromCommandLine(['--config', config.path])
        self.assertEquals(sim.servers["PodA"]["uri"], "https://127.0.0.3:8432/") 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:19,代码来源:test_sim.py

示例3: test_loadArrivalConfig

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def test_loadArrivalConfig(self):
        """
        The arrival policy type and arguments are loaded from the
        [arrival] section of the configuration file specified.
        """
        config = FilePath(self.mktemp())
        config.setContent(
            writePlistToString({
                "arrival": {
                    "factory": "contrib.performance.loadtest.population.SmoothRampUp",
                    "params": {
                        "groups": 10,
                        "groupSize": 1,
                        "interval": 3,
                    },
                },
            })
        )
        sim = LoadSimulator.fromCommandLine(['--config', config.path])
        self.assertEquals(
            sim.arrival,
            Arrival(SmoothRampUp, dict(groups=10, groupSize=1, interval=3))) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:24,代码来源:test_sim.py

示例4: test_loadLogObservers

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def test_loadLogObservers(self):
        """
        Log observers specified in the [observers] section of the
        configuration file are added to the logging system.
        """
        config = FilePath(self.mktemp())
        config.setContent(
            writePlistToString(
                {
                    "observers": [
                        {
                            "type": "contrib.performance.loadtest.population.SimpleStatistics",
                            "params": {},
                        },
                    ]
                }
            )
        )
        sim = LoadSimulator.fromCommandLine(['--config', config.path])
        self.assertEquals(len(sim.observers), 1)
        self.assertIsInstance(sim.observers[0], SimpleStatistics) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:23,代码来源:test_sim.py

示例5: RemoveProfile

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def RemoveProfile(self, ident):
        profiles = self.GetProfileList()
        if not profiles:
            return
        if not profiles["ProfileMetadata"].has_key(ident):
            self.logger.info("Trying to remove not installed profile %s", ident)
            return
        meta = profiles["ProfileMetadata"][ident]
        pprint(meta)
        data = plistlib.writePlistToString({"PayloadType": "Configuration",
             "PayloadIdentifier": ident,
             "PayloadUUID": meta["PayloadUUID"],
             "PayloadVersion": meta["PayloadVersion"]
         })
        self.service.sendPlist({"RequestType":"RemoveProfile", "ProfileIdentifier": plistlib.Data(data)})
        return self.service.recvPlist() 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:18,代码来源:mobile_config.py

示例6: test_string

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [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

示例7: test_indentation_array

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [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

示例8: test_indentation_dict

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

示例9: test_indentation_dict_mix

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

示例10: test_appleformatting

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def test_appleformatting(self):
        pl = plistlib.readPlistFromString(TESTDATA)
        data = plistlib.writePlistToString(pl)
        self.assertEqual(data, TESTDATA,
                         "generated data was not identical to Apple's output") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_plistlib.py

示例11: test_nondictroot

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def test_nondictroot(self):
        test1 = "abc"
        test2 = [1, 2, 3, "abc"]
        result1 = plistlib.readPlistFromString(plistlib.writePlistToString(test1))
        result2 = plistlib.readPlistFromString(plistlib.writePlistToString(test2))
        self.assertEqual(test1, result1)
        self.assertEqual(test2, result2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_plistlib.py

示例12: writePlistToString

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def writePlistToString(rootObject, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if hasattr(plistlib, "dumps"):
            return plistlib.dumps(rootObject)
        elif hasattr(plistlib, "writePlistToBytes"):
            return plistlib.writePlistToBytes(rootObject)
        else:
            return plistlib.writePlistToString(rootObject)
    else:
        ioObject = io.BytesIO()
        writer = PlistWriter(ioObject)
        writer.writeRoot(rootObject)
        return ioObject.getvalue() 
开发者ID:NetEaseGame,项目名称:iOS-private-api-checker,代码行数:16,代码来源:__init__.py

示例13: write_config_to_string

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def write_config_to_string(conf):
    return plistlib.writePlistToString(conf) 
开发者ID:kdart,项目名称:pycopia,代码行数:4,代码来源:plistconfig.py

示例14: plist_dict_to_xml

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def plist_dict_to_xml(plist, key=None):
    """
    Converts a plist dict into an xml string

    :param dict plist: the plist to convert
    :param str key: if the key is set and in the plist it will be the only tag
    returned
    :return: an xml string containing the plist
    """
    import plistlib
    if key and key in plist:
        plist = plist[key]
    xml = plistlib.writePlistToString(plist)
    return '\n'.join(xml.split('\n')[3:-2]) 
开发者ID:nettitude,项目名称:scrounger,代码行数:16,代码来源:ios.py

示例15: sendpacket

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import writePlistToString [as 别名]
def sendpacket(self, req, tag, payload={}):
        payload['ClientVersionString'] = 'usbmux.py by marcan'
        if isinstance(req, int):
            req = [self.TYPE_CONNECT, self.TYPE_LISTEN][req-2]
        payload['MessageType'] = req
        payload['ProgName'] = 'tcprelay'
        BinaryProtocol.sendpacket(self,
            self.TYPE_PLIST, tag, plistlib.writePlistToString(payload)) 
开发者ID:nettitude,项目名称:scrounger,代码行数:10,代码来源:usbmux.py


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