Package: bpylist2
This is a fork of Marketcircle/bpylist. This one is hopefully more responsive to PRs.Implementation of theApple’s Binary
Plistand the NSKeyedArchiver formatUsageBinary PlistsFor reading and writing plain PLists please use stdlibplistliblibrary.KeyedArchivesNSKeyedArchiveris an Apple proprietary serialization format for
Cocoa objects.bpylist2supports reading and writingNSKeyedArchivercompatible archives. The API is similar to the
binary plist API.Unarchiving an objectfrombpylist2importarchiverwithopen('my_archived_object','rb')asf:archiver.unarchive(f.read())Archiving an objectfrombpylist2importarchivermy_object={'foo':'bar','some_array':[1,2,3,4]}archiver.archive(my_object)Custom objectsIf your archive includes classes that are not “standard” Cocoa classes
(NSString,NSNumber,NSDate,NSNull,NSDictionaryorNSArray), you register a Python class that the Cocoa class maps to and
register it.The simplest way to define a class is by providing a python dataclass, for
example you define a class with all the fields of the archived object:@dataclasses.dataclassclassMyClass(DataclassArchiver):int_field:int=0str_field:str=""float_field:float=-1.1list_field:list=dataclasses.field(default_factory=list)Alternatively you can implement custom unarchiving code.The Python class needs to implement theencode_archiveanddecode_archivemethods.## Define a Python Classfrombpylist2importarchiverclassMyClass:first_property=Nonesecond_property=Nonedef__init__(self,first_property,second_property):self.first_property=first_propertyself.second_property=second_propertydefencode_archive(self,archive):archive.encode('first_property',self.first_property)archive.encode('second_property',self.second_property)defdecode_archive(archive):first=archive.decode('first_property')second=archive.decode('second_property')returnMyClass(first,second)When the mapper class is defined, register it with unarchiver:## Register the class for the Cocoa class 'MyCocoaClass'archiver.update_class_map({'MyCocoaClass':FooArchive})Implementation NoteThis package requires the version ofplistlibincluded in the Python 3.8
standard library.  In order to support Python 3.6 and 3.7, a copy of the
Python 3.8plistlibis bundled withbpylist2(Specifically, commit9054967).
This version will only be used ifbpylist2detects it is running on Python < 3.8.How to publish a new version to PyPI$pipinstalltwinewheel$pythonsetup.pysdistbdist_wheel$twineuploaddist/*LicenseMIT LicenseCopyright (c) 2017 Marketcircle Inc.Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.