python类readPlistFromBytes()的实例源码

waresponseparser.py 文件源码 项目:whatsapp-rest-webservice 作者: svub 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parse(self, xml, pvars):

        #tmp = minidom.parseString(xml)

        if sys.version_info >= (3, 0):
            pl = plistlib.readPlistFromBytes(xml.encode());
        else:
            pl = plistlib.readPlistFromString(xml);

        parsed= {}
        pvars = self.getVars(pvars)

        for k,v in pvars.items():
            parsed[k] = pl[k] if  k in pl else None

        return parsed;
test_plistlib.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_dataobject_deprecated(self):
        in_data = { 'key': plistlib.Data(b'hello') }
        out_data = { 'key': b'hello' }

        buf = plistlib.dumps(in_data)

        cur = plistlib.loads(buf)
        self.assertEqual(cur, out_data)
        self.assertNotEqual(cur, in_data)

        cur = plistlib.loads(buf, use_builtin_types=False)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data)

        with self.assertWarns(DeprecationWarning):
            cur = plistlib.readPlistFromBytes(buf)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data)
waresponseparser.py 文件源码 项目:yowsup 作者: colonyhq 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def parse(self, xml, pvars):

        #tmp = minidom.parseString(xml)

        if sys.version_info >= (3, 0):
            pl = plistlib.readPlistFromBytes(xml.encode());
        else:
            pl = plistlib.readPlistFromString(xml);

        parsed= {}
        pvars = self.getVars(pvars)

        for k,v in pvars.items():
            parsed[k] = pl[k] if  k in pl else None

        return parsed;
test_plistlib.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_dataobject_deprecated(self):
        in_data = { 'key': plistlib.Data(b'hello') }
        out_data = { 'key': b'hello' }

        buf = plistlib.dumps(in_data)

        cur = plistlib.loads(buf)
        self.assertEqual(cur, out_data)
        self.assertNotEqual(cur, in_data)

        cur = plistlib.loads(buf, use_builtin_types=False)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data)

        with self.assertWarns(DeprecationWarning):
            cur = plistlib.readPlistFromBytes(buf)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data)
bbcode.py 文件源码 项目:SublimeKSP 作者: nojanath 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def run(self, *args, **kwargs):
        view = sublime.active_window().active_view()

        #settings = sublime.load_settings('KSP.sublime-settings')
        #scheme_file = settings.get('color_scheme', 'Packages/SublimeKSP/KScript Light.tmTheme')
        scheme_file = 'Packages/SublimeKSP/KScript Light.tmTheme'
        plist = readPlistFromBytes(sublime.load_binary_resource(scheme_file))

        result = ['[pre]']
        start, end = view.sel()[0].a, view.sel()[0].b
        if start == end:
            start, end = 0, view.size()
        for a, b, scopes in get_ranges(view.scope_name(i) for i in range(start, end)):
            result.append(self.apply_style(scopes, plist, view.substr(sublime.Region(start+a, start+b))))
        result.append('[/pre]')
        sublime.set_clipboard(''.join(result))
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_bytes(self):
        pl = self._create()
        data = plistlib.writePlistToBytes(pl)
        pl2 = plistlib.readPlistFromBytes(data)
        self.assertEqual(dict(pl), dict(pl2))
        data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2)
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_appleformatting(self):
        pl = plistlib.readPlistFromBytes(TESTDATA)
        data = plistlib.writePlistToBytes(pl)
        self.assertEqual(data, TESTDATA,
                         "generated data was not identical to Apple's output")
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_appleformattingfromliteral(self):
        pl = self._create()
        pl2 = plistlib.readPlistFromBytes(TESTDATA)
        self.assertEqual(dict(pl), dict(pl2),
                         "generated data was not identical to Apple's output")
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_nondictroot(self):
        test1 = "abc"
        test2 = [1, 2, 3, "abc"]
        result1 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test1))
        result2 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test2))
        self.assertEqual(test1, result1)
        self.assertEqual(test2, result2)
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_invalidarray(self):
        for i in ["<key>key inside an array</key>",
                  "<key>key inside an array2</key><real>3</real>",
                  "<true/><key>key inside an array3</key>"]:
            self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                              ("<plist><array>%s</array></plist>"%i).encode())
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_invalidinteger(self):
        self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                          b"<plist><integer>not integer</integer></plist>")
test_plistlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_invalidreal(self):
        self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                          b"<plist><integer>not real</integer></plist>")
ToolTipHelper.py 文件源码 项目:ToolTip-Helper 作者: AvitanI 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def read_scheme(self, scheme):
        """Converts supplied scheme(bytes) to python dict."""

        return  readPlistFromBytes(scheme)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_bytes(self):
        pl = self._create()
        data = plistlib.writePlistToBytes(pl)
        pl2 = plistlib.readPlistFromBytes(data)
        self.assertEqual(dict(pl), dict(pl2))
        data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromBytes(plistlib.writePlistToBytes(data)), data)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 18 收藏 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.readPlistFromBytes(plistlib.writePlistToBytes(data)), data)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromBytes(plistlib.writePlistToBytes(data)), data)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_appleformatting(self):
        pl = plistlib.readPlistFromBytes(TESTDATA)
        data = plistlib.writePlistToBytes(pl)
        self.assertEqual(data, TESTDATA,
                         "generated data was not identical to Apple's output")
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_nondictroot(self):
        test1 = "abc"
        test2 = [1, 2, 3, "abc"]
        result1 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test1))
        result2 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test2))
        self.assertEqual(test1, result1)
        self.assertEqual(test2, result2)
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_invalidarray(self):
        for i in ["<key>key inside an array</key>",
                  "<key>key inside an array2</key><real>3</real>",
                  "<true/><key>key inside an array3</key>"]:
            self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                              ("<plist><array>%s</array></plist>"%i).encode())
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_invaliddict(self):
        for i in ["<key><true/>k</key><string>compound key</string>",
                  "<key>single key</key>",
                  "<string>missing key</string>",
                  "<key>k1</key><string>v1</string><real>5.3</real>"
                  "<key>k1</key><key>k2</key><string>double key</string>"]:
            self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                              ("<plist><dict>%s</dict></plist>"%i).encode())
            self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                              ("<plist><array><dict>%s</dict></array></plist>"%i).encode())
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_invalidinteger(self):
        self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                          b"<plist><integer>not integer</integer></plist>")
test_plistlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_invalidreal(self):
        self.assertRaises(ValueError, plistlib.readPlistFromBytes,
                          b"<plist><integer>not real</integer></plist>")
test_plistlib.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_bytes_deprecated(self):
        pl = {
            'key': 42,
            'sub': {
                'key': 9,
                'alt': 'value',
                'data': b'buffer',
            }
        }
        with self.assertWarns(DeprecationWarning):
            data = plistlib.writePlistToBytes(pl)

        with self.assertWarns(DeprecationWarning):
            pl2 = plistlib.readPlistFromBytes(data)

        self.assertIsInstance(pl2, plistlib._InternalDict)
        self.assertEqual(pl2, plistlib._InternalDict(
            key=42,
            sub=plistlib._InternalDict(
                key=9,
                alt='value',
                data=plistlib.Data(b'buffer'),
            )
        ))

        with self.assertWarns(DeprecationWarning):
            data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2)
test_plistlib.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_bytes_deprecated(self):
        pl = {
            'key': 42,
            'sub': {
                'key': 9,
                'alt': 'value',
                'data': b'buffer',
            }
        }
        with self.assertWarns(DeprecationWarning):
            data = plistlib.writePlistToBytes(pl)

        with self.assertWarns(DeprecationWarning):
            pl2 = plistlib.readPlistFromBytes(data)

        self.assertIsInstance(pl2, plistlib._InternalDict)
        self.assertEqual(pl2, plistlib._InternalDict(
            key=42,
            sub=plistlib._InternalDict(
                key=9,
                alt='value',
                data=plistlib.Data(b'buffer'),
            )
        ))

        with self.assertWarns(DeprecationWarning):
            data2 = plistlib.writePlistToBytes(pl2)
        self.assertEqual(data, data2)
color_scheme.py 文件源码 项目:sublime-color-scheme-unit 作者: gerardroche 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def load_color_scheme_resource(color_scheme):
    return plistlib.readPlistFromBytes(bytes(load_resource(color_scheme), 'UTF-8'))
ToolTipHelper.py 文件源码 项目:ToolTip-Helper 作者: doobleweb 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def read_scheme(self, scheme):
        """Converts supplied scheme(bytes) to python dict."""

        return  readPlistFromBytes(scheme)
vhdl_navigation.py 文件源码 项目:SmartVHDL 作者: TheClams 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def init_css():
    global tooltip_css
    color_plist = readPlistFromBytes(sublime.load_binary_resource(pref_settings.get('color_scheme')))
    color_dict = {}
    for x in color_plist['settings'] :
        if 'scope' in x:
            for s in x['scope'].split(','):
                color_dict[s.strip()] = x['settings']
    color_dict['__GLOBAL__'] = color_plist['settings'][0]['settings'] # first settings contains global settings, without scope(hopefully)
    bg = int(color_dict['__GLOBAL__']['background'][1:],16)
    fg = int(color_dict['__GLOBAL__']['foreground'][1:],16)
    # Get color for keyword, support, storage, default to foreground
    kw  = fg if 'keyword' not in color_dict else int(color_dict['keyword']['foreground'][1:],16)
    sup = fg if 'support' not in color_dict else int(color_dict['support']['foreground'][1:],16)
    sto = fg if 'storage' not in color_dict else int(color_dict['storage']['foreground'][1:],16)
    ent = fg if 'entity' not in color_dict else int(color_dict['entity']['foreground'][1:],16)
    fct = fg if 'support.function' not in color_dict else int(color_dict['support.function']['foreground'][1:],16)
    op  = fg if 'keyword.operator' not in color_dict else int(color_dict['keyword.operator']['foreground'][1:],16)
    num = fg if 'constant.numeric' not in color_dict else int(color_dict['constant.numeric']['foreground'][1:],16)
    st  = fg if 'string' not in color_dict else int(color_dict['string']['foreground'][1:],16)
    # Create background and border color based on the background color
    b = bg & 255
    g = (bg>>8) & 255
    r = (bg>>16) & 255
    if b > 128:
        bgHtml = b - 0x33
        bgBody = b - 0x20
    else:
        bgHtml = b + 0x33
        bgBody = b + 0x20
    if g > 128:
        bgHtml += (g - 0x33)<<8
        bgBody += (g - 0x20)<<8
    else:
        bgHtml += (g + 0x33)<<8
        bgBody += (g + 0x20)<<8
    if r > 128:
        bgHtml += (r - 0x33)<<16
        bgBody += (r - 0x20)<<16
    else:
        bgHtml += (r + 0x33)<<16
        bgBody += (r + 0x20)<<16
    tooltip_css = 'html {{ background-color: #{bg:06x}; color: #{fg:06x}; }}\n'.format(bg=bgHtml, fg=fg)
    tooltip_css+= 'body {{ background-color: #{bg:06x}; margin: 1px; font-size: 1em; }}\n'.format(bg=bgBody)
    tooltip_css+= 'p {padding-left: 0.6em;}\n'
    tooltip_css+= '.content {margin: 0.8em;}\n'
    tooltip_css+= '.keyword {{color: #{c:06x};}}\n'.format(c=kw)
    tooltip_css+= '.support {{color: #{c:06x};}}\n'.format(c=sup)
    tooltip_css+= '.storage {{color: #{c:06x};}}\n'.format(c=sto)
    tooltip_css+= '.function {{color: #{c:06x};}}\n'.format(c=fct)
    tooltip_css+= '.entity {{color: #{c:06x};}}\n'.format(c=ent)
    tooltip_css+= '.operator {{color: #{c:06x};}}\n'.format(c=op)
    tooltip_css+= '.numeric {{color: #{c:06x};}}\n'.format(c=num)
    tooltip_css+= '.string {{color: #{c:06x};}}\n'.format(c=st)
    tooltip_css+= '.extra-info {font-size: 0.9em; }\n'

############################################################################


问题


面经


文章

微信
公众号

扫码关注公众号