### Load Binary Property List from File Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md This example demonstrates the basic usage of `ccl_bplist` to load a binary property list from a file. It shows how to import the module, open a file in binary read mode, and use `ccl_bplist.load()` to parse its contents into a Python object. ```python >>> import ccl_bplist >>> f = open("plist.plist", "rb") >>> plist = ccl_bplist.load(f) >>> >>> plist {'$objects': ['$null', {'apiKey': UID: 10, 'eventLog': UID: 7, 'locale': UID: 12, '$class': UID: 14, 'pauseTime': UID: 4, 'totalErrorCount': 0, 'internetAvailable': True, 'errors': UID: 9, 'userID': UID: 0, 'appVersion': UID: 11, 'latitude': 0.0, 'eventCounts': UID: 5, 'eventLogComplete': True, 'crashed': False, 'pageViewCount': 0, 'startTime': UID: 2, 'pauseIntervalMillis': 0, 'gender': -1, 'longitude': 0.0, 'serializationVersion': 1, 'timeZone': UID: 13, 'accuracy': 0.0}, {'$class': UID: 3, 'NS.time': 378032076.116256}, {'$classes': ['NSDate', 'NSObject'], '$classname': 'NSDate'}, {'$class': UID: 3, 'NS.time': 378032077.674404}, {'$class': UID: 6, 'NS.keys': [], 'NS.objects': []}, {'$classes': ['NSMutableDictionary', 'NSDictionary', 'NSObject'], '$classname': 'NSMutableDictionary'}, {'$class': UID: 8, 'NS.objects': []}, {'$classes': ['NSMutableArray', 'NSArray', 'NSObject'], '$classname': 'NSMutableArray'}, {'$class': UID: 8, 'NS.objects': []}, 'BMPNB5HT2H63KM42BB83', '4.0.1', 'en_GB', 'Europe/London', {'$classes': ['FlurrySession', 'NSObject'], '$classname': 'FlurrySession'}], '$top': {'root': UID: 1}, '$version': 100000, '$archiver': 'NSKeyedArchiver'} ``` -------------------------------- ### Deserialize Full NSKeyedArchiver Structure Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md This example shows how to override the default behavior of `ccl_bplist.deserialise_NsKeyedArchiver()` to parse the entire NSKeyedArchiver structure, including the root object reference, by setting the `parse_whole_structure` parameter to `True`. ```python >>> ns_keyed_archiver_obj = ccl_bplist.deserialise_NsKeyedArchiver(plist, parse_whole_structure=True) >>> ns_keyed_archiver_obj {'root': UID: 1} ``` -------------------------------- ### Binary Property List Type to Python Type Mapping Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md This section provides a reference table detailing how binary property list data types are translated into their corresponding native Python types by the `ccl_bplist` module during the loading process. ```APIDOC Property List Type | Returned Python Type ------------------ | -------------------- null | None true | True false | False integer | int real | float uid | int date | datetime.datetime string | str data | bytes array | list dict | dict set | list ``` -------------------------------- ### Demonstrate NSDate to Python Datetime Conversion Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Illustrates the automatic conversion of an `NSDate` serialized object. This sequence shows the raw object, its class metadata, then enables the converter and accesses the object as a native Python `datetime` object, and finally disables the converter. ```python ns_keyed_archiver_obj["root"]["startTime"] ``` ```python ns_keyed_archiver_obj["root"]["startTime"]["$class"] ``` ```python ccl_bplist.set_object_converter(ccl_bplist.NSKeyedArchiver_common_objects_convertor) ns_keyed_archiver_obj["root"]["startTime"] ``` ```python ccl_bplist.set_object_converter(lambda x: x) ``` -------------------------------- ### Demonstrate NSNull to Python None Conversion Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Illustrates the automatic conversion of a serialized `Null` value (represented as `'$null'`). This sequence shows the raw string representation, then enables the converter and accesses the object as Python's `None`. ```python ns_keyed_archiver_obj["root"]["userID"] ``` ```python ccl_bplist.set_object_converter(ccl_bplist.NSKeyedArchiver_common_objects_convertor) print(ns_keyed_archiver_obj["root"]["userID"]) ``` -------------------------------- ### Demonstrate NSDictionary to Python Dictionary Conversion Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Illustrates the automatic conversion of an `NSDictionary` serialized object. This sequence shows the raw object, its class metadata, then enables the converter and accesses the object as a native Python dictionary, and finally disables the converter. ```python ns_keyed_archiver_obj["root"]["eventCounts"] ``` ```python ns_keyed_archiver_obj["root"]["eventCounts"]["$class"] ``` ```python ccl_bplist.set_object_converter(ccl_bplist.NSKeyedArchiver_common_objects_convertor) ns_keyed_archiver_obj["root"]["eventCounts"] ``` ```python ccl_bplist.set_object_converter(lambda x: x) ``` -------------------------------- ### Demonstrate NSMutableArray to Python List Conversion Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Shows the result of accessing an `NSMutableArray` serialized object after the automatic converter has been globally enabled. The object is automatically transformed into a native Python list, simplifying data access. ```python ns_keyed_archiver_obj["root"]["eventLog"] ``` -------------------------------- ### Configure Global Automatic Object Conversion Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Illustrates how to enable the built-in `NSKeyedArchiver_common_objects_convertor` in `ccl_bplist` for module-wide automatic conversion of common NSObjects to native Python types. Also shows how to disable this functionality by setting a pass-through converter. ```python ccl_bplist.set_object_converter(ccl_bplist.NSKeyedArchiver_common_objects_convertor) ``` ```python ccl_bplist.set_object_converter(lambda x: x) ``` -------------------------------- ### Inspect Raw NSKeyed Archiver Object Structure Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md Demonstrates how to access and inspect the raw structure of an NSKeyed Archiver serialized object before automatic conversion, revealing its internal representation including the '$class' and 'NS.objects' keys, and how to query its Objective-C class hierarchy. ```python ns_keyed_archiver_obj["root"]["eventLog"] ``` ```python ns_keyed_archiver_obj["root"]["eventLog"]["$class"] ``` -------------------------------- ### Accessing UID Objects in Deserialized NSKeyedArchiver Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md This snippet demonstrates how `UID` objects, which represent references to an object table within NSKeyedArchiver, are automatically looked up and resolved by `ccl_bplist` when accessed. Accessing a `UID` within a dictionary or list triggers its resolution to the actual referenced object. ```python >>> ns_keyed_archiver_obj["root"] {'apiKey': UID: 10, 'eventLog': UID: 7, 'locale': UID: 12, '$class': UID: 14, 'eventLogComplete': True, 'crashed': False, 'pageViewCount': 0, 'startTime': UID: 2, 'pauseTime': UID: 4, 'totalErrorCount': 0, 'internetAvailable': True, 'errors': UID: 9, 'pauseIntervalMillis': 0, 'gender': -1, 'userID': UID: 0, 'appVersion': UID: 11, 'longitude': 0.0, 'serializationVersion': 1, 'latitude': 0.0, 'timeZone': UID: 13, 'accuracy': 0.0, 'eventCounts': UID: 5} ``` -------------------------------- ### Deserialize NSKeyedArchiver Object Source: https://github.com/cclgroupltd/ccl-bplist/blob/master/README.md This snippet demonstrates how to deserialize an NSKeyedArchiver object using `ccl_bplist.deserialise_NsKeyedArchiver()`. It converts the complex archived structure into a more manageable Python dictionary, typically extracting the primary data structure. ```python >>> ns_keyed_archiver_obj = ccl_bplist.deserialise_NsKeyedArchiver(plist) >>> ns_keyed_archiver_obj {'apiKey': UID: 10, 'eventLog': UID: 7, 'locale': UID: 12, '$class': UID: 14, 'eventLogComplete': True, 'crashed': False, 'pageViewCount': 0, 'startTime': UID: 2, 'pauseTime': UID: 4, 'totalErrorCount': 0, 'internetAvailable': True, 'errors': UID: 9, 'pauseIntervalMillis': 0, 'gender': -1, 'userID': UID: 0, 'appVersion': UID: 11, 'longitude': 0.0, 'serializationVersion': 1, 'latitude': 0.0, 'timeZone': UID: 13, 'accuracy': 0.0, 'eventCounts': UID: 5} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.