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