Module implementing a library for reading and writing binary property list files.
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.
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 bytes object.
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.
Plist generation example:
from binplistlib 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) as e: print("Something bad happened:", e)Plist parsing example:
from binplistlib import * try: plist = readPlist("example.plist") print(plist) except (InvalidPlistException, NotBinaryPlistException) as e: print("Not a plist:", e)
PlistByteCounts |
PlistTrailer |
__all__ |
apple_reference_date_offset |
BoolWrapper | Class wrapping a boolean value. |
Data | Class implementing a wrapper around bytes types for representing Data values. |
HashableWrapper | Class wrapping a hashable value. |
InvalidPlistException | Exception raised when the plist is incorrectly formatted. |
NotBinaryPlistException | Exception raised when a binary plist was expected but not encountered. |
PlistReader | Class implementing the plist reader. |
PlistWriter | Class implementing the plist writer. |
Uid | Class implementing a wrapper around integers for representing UID values. |
is_stream_binary_plist | Module function to check, if the stream is a binary plist. |
readPlist | Module function to read a plist file. |
readPlistFromBytes | Module function to read from a plist bytes object. |
writePlist | Module function to write a plist file. |
writePlistToBytes | Module function to write a plist bytes object. |
Class wrapping a boolean value.
None |
None |
BoolWrapper | Constructor |
__repr__ | Special method to generate a representation of the object. |
None |
Constructor
Special method to generate a representation of the object.
Class implementing a wrapper around bytes types for representing Data values.
None |
None |
None |
None |
Class wrapping a hashable value.
None |
None |
HashableWrapper | Constructor |
__repr__ | Special method to generate a representation of the object. |
None |
Constructor
Special method to generate a representation of the object.
Exception raised when the plist is incorrectly formatted.
None |
None |
None |
None |
Exception raised when a binary plist was expected but not encountered.
None |
None |
None |
None |
Class implementing the plist reader.
contents |
currentOffset |
file |
offsets |
trailer |
None |
PlistReader | Constructor |
getSizedInteger | Public method to read an integer of a specific size. |
parse | Public method to parse the plist data. |
proc_extra | |
readArray | Public method to read an Array object. |
readAsciiString | Public method to read an ASCII encoded string. |
readData | Public method to read some bytes. |
readDate | Public method to read a date. |
readDict | Public method to read a Dictionary object. |
readInteger | Public method to read an Integer object. |
readObject | Public method to read the object data. |
readReal | Public method to read a Real object. |
readRefs | Public method to read References. |
readRoot | Public method to read the root object. |
readUid | Public method to read a UID. |
readUnicode | Public method to read an Unicode encoded string. |
reset | Public method to reset the instance object. |
setCurrentOffsetToObjectNumber | Public method to set the current offset. |
None |
Constructor
Public method to read an integer of a specific size.
Public method to parse the plist data.
Public method to read an Array object.
Public method to read an ASCII encoded string.
Public method to read some bytes.
Public method to read a date.
Public method to read a Dictionary object.
Public method to read an Integer object.
Public method to read the object data.
Public method to read a Real object.
Public method to read References.
Public method to read the root object.
Public method to read a UID.
Public method to read an Unicode encoded string.
Public method to reset the instance object.
Public method to set the current offset.
Class implementing the plist writer.
byteCounts |
computedUniques |
file |
header |
referencePositions |
trailer |
wrappedFalse |
wrappedTrue |
writtenReferences |
None |
PlistWriter | Constructor |
__checkKey | Private method to check the validity of a key. |
__processSize | Private method to process a size. |
binaryInt | Public method to pack an integer object. |
binaryReal | Public method to pack a real object. |
computeOffsets | Public method to compute offsets of an object. |
incrementByteCount | Public method to increment the byte count. |
intSize | Public method to determine the number of bytes necessary to store the given integer. |
positionOfObjectReference | Public method to get the position of an object. |
proc_variable_length | |
realSize | Public method to determine the number of bytes necessary to store the given real. |
reset | Public method to reset the instance object. |
wrapRoot | Public method to generate object wrappers. |
writeObject | Public method to serialize the given object to the output. |
writeObjectReference | Public method to write an object reference. |
writeOffsetTable | Public method to write all of the object reference offsets. |
writeRoot | Public method to write an object to a plist file. |
None |
Constructor
Private method to check the validity of a key.
Private method to process a size.
Public method to pack an integer object.
Public method to pack a real object.
Public method to compute offsets of an object.
Public method to increment the byte count.
Public method to determine the number of bytes necessary to store the given integer.
Public method to get the position of an object.
If the given object has been written already, return its position in the offset table. Otherwise, return None.
Public method to determine the number of bytes necessary to store the given real.
Public method to reset the instance object.
Public method to generate object wrappers.
Public method to serialize the given object to the output.
Public method to write an object reference.
Tries to write an object reference, adding it to the references table. Does not write the actual object bytes or set the reference position. Returns a tuple of whether the object was a new reference (True if it was, False if it already was in the reference table) and the new output.
Public method to write all of the object reference offsets.
Public method to write an object to a plist file.
Strategy is:
Class implementing a wrapper around integers for representing UID values.
This is used in keyed archiving.
None |
None |
__repr__ | Special method to return an object representation. |
None |
Special method to return an object representation.
Module function to check, if the stream is a binary plist.
Module function to read a plist file.
Module function to read from a plist bytes object.
Module function to write a plist file.
Module function to write a plist bytes object.