gecko-dev/third_party/python/biplist
Mike Shal b64b81d0c5 Bug 1522931 - Vendor biplist; r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D26390

--HG--
extra : moz-landing-system : lando
2019-04-12 19:00:15 +00:00
..
biplist Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
tests Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
AUTHORS Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
LICENSE Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
MANIFEST.in Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
PKG-INFO Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
README.md Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
setup.cfg Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00
setup.py Bug 1522931 - Vendor biplist; r=froydnj 2019-04-12 19:00:15 +00:00

README.md

biplist

biplist is a binary plist parser/generator for Python.

About

Binary Property List (plist) files provide a faster and smaller serialization format for property lists on OS X. This is a library for generating binary plists which can be read by OS X, iOS, or other clients.

API

The API models the plistlib API, and will call through to plistlib when XML serialization or deserialization is required.

To generate plists with UID values, wrap the values with the Uid object. The value must be an int.

To generate plists with NSData/CFData values, wrap the values with the Data object. The value must be a string.

Date values can only be datetime.datetime objects.

The exceptions InvalidPlistException and NotBinaryPlistException may be thrown to indicate that the data cannot be serialized or deserialized as a binary plist.

Installation

To install the latest release version:

sudo easy_install biplist

Examples

Plist generation example:

from biplist import *
from datetime import datetime
plist = {'aKey':'aValue',
         '0':1.322,
         'now':datetime.now(),
         'list':[1,2,3],
         'tuple':('a','b','c')
         }
try:
    writePlist(plist, "example.plist")
except (InvalidPlistException, NotBinaryPlistException), e:
    print "Something bad happened:", e

Plist parsing example:

from biplist import *
try:
    plist = readPlist("example.plist")
    print plist
except (InvalidPlistException, NotBinaryPlistException), e:
    print "Not a plist:", e