python类writePlistToString()的实例源码

glifLib2.py 文件源码 项目:inter 作者: rsms 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def writeContents(self):
        """Write the contents.plist file out to disk. Call this method when
        you're done writing glyphs.
        """
        from plistlib import writePlistToString
        contentsPath = os.path.join(self.dirName, "contents.plist")
        # We need to force Unix line endings, even in OS9 MacPython in FL,
        # so we do the writing to file ourselves.
        plist = writePlistToString(self.contents)
        f = open(contentsPath, WRITE_MODE)
        f.write(plist)
        f.close()

    # read caching
__init__.py 文件源码 项目:iOS-private-api-checker 作者: NetEaseGame 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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()
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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")
test_plistlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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")
test_plistlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
__init__.py 文件源码 项目:timer-workflow 作者: 5fth 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def writePlistToString(rootObject, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if six.PY3:
            return plistlib.writePlistToBytes(rootObject)
        else:
            return plistlib.writePlistToString(rootObject)
    else:
        io = six.BytesIO()
        writer = PlistWriter(io)
        writer.writeRoot(rootObject)
        return io.getvalue()
core.py 文件源码 项目:timer-workflow 作者: 5fth 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def writePlist(obj, path):
    if not os.path.isabs(path):
        path = storage(path)

    s = plistlib.writePlistToString(obj)
    with codecs.open(path, "w", "utf-8") as f:
        f.write(s)
usbmux.py 文件源码 项目:wptagent 作者: WPO-Foundation 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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))
__init__.py 文件源码 项目:Alfred_SourceTree 作者: yourtion 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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()
genconfig.py 文件源码 项目:devpi 作者: devpi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def gen_launchd(tw, config, writer):
    devpibin = py.path.local(sys.argv[0])
    plist_content = write_plist_to_bytes(OrderedDict([
        ("Label", "net.devpi"),
        ("ProgramArguments", [str(devpibin)] + config.args._raw),
        ("RunAtLoad", True),
    ]))
    writer("net.devpi.plist", plist_content)
usbmux.py 文件源码 项目:needle 作者: mwrlabs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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))
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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")
test_plistlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)
test_plistlib.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
test_plistlib.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data)


问题


面经


文章

微信
公众号

扫码关注公众号