wooster / biplist Goto Github PK
View Code? Open in Web Editor NEWThis project now lives on BitBucket.
Home Page: https://bitbucket.org/wooster/biplist
License: BSD 3-Clause "New" or "Revised" License
This project now lives on BitBucket.
Home Page: https://bitbucket.org/wooster/biplist
License: BSD 3-Clause "New" or "Revised" License
Hi,
I have a weird encoding trouble using biplist and spend many days to reproduce the problem, here's the test code:
#!/usr/bin/env python
# -*- coding: utf-8 -*
import biplist
import unittest
class TestEncoding(unittest.TestCase):
def test_encoding(self):
en = { 'key': 'ON' } # 'ON' => '\x4f\x4e'
zh = { 'key': u'低' } # '低' => '\u4f4e'
# Comment the following line, then test succeed.
biplist.writePlistToString(en)
zh_plist = biplist.writePlistToString(zh)
zh2 = biplist.readPlistFromString(zh_plist)
self.assertDictEqual(zh, zh2)
test case failed if writePlist twice. If I comment biplist.writePlistToString(en)
, it will success. If I change 'ON' or u'低' to other word, it also success.
I'm having trouble with the following data; when trying to parse it with biplist I get the error 'InvalidPlistException: Encountered integer longer than 16 bytes.'
I don't think the data is bad (it works in the program that generated it) so I'm wondering if there's a problem in the way biplist handles it?
bplist00\xd4\x01\x02\x03\x04\x05}~\x7fX$objectsY$archiverX$versionT$top\xaf\x10\x13\x06\x07\x16\x1b"'.3:?FKRW^cjovU$null\xd3\x08\t\n\x0b\x10\x15WNS.keysZNS.objectsV$class\xa4\x0c\r\x0e\x0f\x80\x02\x80\x04\x80\x06\x80\x08\xa4\x11\x12\x13\x14\x80\n\x80\x0c\x80\x0e\x80\x10\x80\x12\xd2\x17\x18\x19\x1aYNS.stringV$classXfullname\x80\x03\xd2\x1c\x1d\x1e!X$classesZ$classname\xa2\x1f
XNSStringXNSObjectXNSString\xd2#$%&YNS.stringV$classWaddress\x80\x05\xd2()*-X$classesZ$classname\xa2+,XNSStringXNSObjectXNSString\xd2/012YNS.stringV$classUphone\x80\x07\xd24569X$classesZ$classname\xa278XNSStringXNSObjectXNSString\xd2;<=>YNS.stringV$classUemail\x80\t\xd2@ABEX$classesZ$classname\xa2CDXNSStringXNSObjectXNSString\xd2GHIJYNS.stringV$class[Test Client\x80\x0b\xd2LMNQX$classesZ$classname\xa2OPXNSStringXNSObjectXNSString\xd2STUVYNS.stringV$class^123 ABC Street\x80\r\xd2XYZ]X$classesZ$classname\xa2[\XNSStringXNSObjectXNSString\xd2_`abYNS.stringV$classT1234\x80\x0f\xd2defiX$classesZ$classname\xa2ghXNSStringXNSObjectXNSString\xd2klmnYNS.stringV$class][email protected]\x80\x11\xd2pqruX$classesZ$classname\xa2stXNSStringXNSObjectXNSString\xd2wxy|X$classesZ$classname\xa2z{\NSDictionaryXNSObject\NSDictionary_\x10\x0fNSKeyedArchiver\x12\x00\x01\x86\xa0\xd1\x80\x81Troot\x80\x01\x00\x08\x00\x11\x00\x1a\x00$\x00-\x002\x00H\x00N\x00U\x00]\x00h\x00o\x00t\x00v\x00x\x00z\x00|\x00\x81\x00\x83\x00\x85\x00\x87\x00\x89\x00\x8b\x00\x90\x00\x9a\x00\xa1\x00\xaa\x00\xac\x00\xb1\x00\xba\x00\xc5\x00\xc8\x00\xd1\x00\xda\x00\xe3\x00\xe8\x00\xf2\x00\xf9\x01\x01\x01\x03\x01\x08\x01\x11\x01\x1c\x01\x1f\x01(\x011\x01:\x01?\x01I\x01P\x01V\x01X\x01]\x01f\x01q\x01t\x01}\x01\x86\x01\x8f\x01\x94\x01\x9e\x01\xa5\x01\xab\x01\xad\x01\xb2\x01\xbb\x01\xc6\x01\xc9\x01\xd2\x01\xdb\x01\xe4\x01\xe9\x01\xf3\x01\xfa\x02\x06\x02\x08\x02\r\x02\x16\x02!\x02$\x02-\x026\x02?\x02D\x02N\x02U\x02d\x02f\x02k\x02t\x02\x7f\x02\x82\x02\x8b\x02\x94\x02\x9d\x02\xa2\x02\xac\x02\xb3\x02\xb8\x02\xba\x02\xbf\x02\xc8\x02\xd3\x02\xd6\x02\xdf\x02\xe8\x02\xf1\x02\xf6\x03\x00\x03\x07\x03\x15\x03\x17\x03\x1c\x03%\x030\x033\x03<\x03E\x03N\x03S\x03\\x03g\x03j\x03w\x03\x80\x03\x8d\x03\x9f\x03\xa4\x03\xa7\x03\xac\x00\x00\x00\x00\x00\x00\x02\x01\x00\x00\x00\x00\x00\x00\x00\x82\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\xae
I'm noticing confusion in how Uids are being handled, when a plist is going to contain both UIds and Ints. Example:
# int to Uid
a = {'$archiver': 'NSKeyedArchiver',
'$objects': ['$null',
{'$class': Uid(3), 'somekey': Uid(2), 'someOtherKey': 3},
'object value as string',
{'$classes': ['Archived', 'NSObject'], '$classname': 'Archived'}],
'$top': {'root': Uid(1)},
'$version': 100000}
biplist.readPlistFromString(biplist.writePlistToString(a))
{'$archiver': 'NSKeyedArchiver',
'$objects': ['$null',
{'$class': Uid(3),
'someOtherKey': Uid(3),
'somekey': Uid(2)},
'object value as string',
{'$classes': ['Archived', 'NSObject'], '$classname': 'Archived'}],
'$top': {'root': Uid(1)},
'$version': 100000}
# Uid to int
a = {'$archiver': 'NSKeyedArchiver',
'$objects': ['$null',
{'$class': 1, 'somekey': 2},
'object value as string',
{'$classes': ['Archived', 'NSObject'], '$classname': 'Archived'}],
'$top': {'root': Uid(1)},
'$version': 100000}
biplist.readPlistFromString(biplist.writePlistToString(a))
{'$archiver': 'NSKeyedArchiver',
'$objects': ['$null',
{'$class': 1, 'somekey': 2},
'object value as string',
{'$classes': ['Archived', 'NSObject'], '$classname': 'Archived'}],
'$top': {'root': 1},
'$version': 100000}
OS X 10.11
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
IPython 4.0.0 -- An enhanced Interactive Python.
Hello, Wooster! it appear some problem when run python3
module 'plistlib' has no attribute 'Data'
how can I resolve it?
thank you and waiting for your reply
The biplist 0.9 release shows the failure...
======================================================================
ERROR: testLargeDates (test_valid.TestValidPlistFile)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/sw/src/fink.build/biplist-py34-0.9-1/biplist-0.9/tests/test_valid.py", line 72, in testLargeDates
self.assertEqual(result['lastShownRatePromptDate'], datetime.datetime(1, 12, 30, 0, 0, 0))
KeyError: 'lastShownRatePromptDate'
when built against python 3.4.2, coverage 3.7.1, pytest 2.6.1 and six 1.8.0 on x86_64-apple-darwin14.
Writing this because of gentoo/guru@5fe6976
Source compiled.
python3_3: running distutils-r1_run_phase python_test
....F...........................FAIL: testFileRead (test_valid.TestValidPlistFile)
Traceback (most recent call last):
File "/mnt/gen2/TmpDir/portage/dev-python/biplist-0.5-r1/work/biplist-0.5/tests/test_valid.py", line 26, in testFileRead
self.validateSimpleBinaryRoot(result)
File "/mnt/gen2/TmpDir/portage/dev-python/biplist-0.5-r1/work/biplist-0.5/tests/test_valid.py", line 15, in validateSimpleBinaryRoot
self.assertEquals(root[six.b('dateItem')], datetime.datetime(2010, 8, 19, 22, 27, 30, 385449), "dates not equal" )
AssertionError: datetime.datetime(2010, 8, 19, 22, 27, 30, 385448) != datetime.datetime(2010, 8, 19, 22, 27, 30, 385449) : dates not equal
Ran 32 tests in 0.138s
FAILED (failures=1)
When I tried to write a plist file, I found that the file encoding always being "latin1". Any solutions for specifying as utf-8?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.