bpylist2

4.1.1 · active · verified Thu Apr 16

bpylist2 is a Python library for parsing and generating NSKeyedArchiver archives, an Apple proprietary serialization format for Cocoa objects. It is a fork of the original `Marketcircle/bpylist` project, maintained to be more responsive to contributions. While it specializes in NSKeyedArchiver, it also includes a bundled `plistlib` compatible with Python 3.8 for older Python versions, though for standard binary plists, the `stdlib` `plistlib` is recommended. The current version is 4.1.1, released in September 2023.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the basic workflow of archiving a Python dictionary into `NSKeyedArchiver` format bytes and then unarchiving it back. This covers the most common use case for standard Python types.

from bpylist2 import archiver
import io

# An object to archive
my_object = {'foo': 'bar', 'some_array': [1, 2, 3, 4], 'nested': {'key': 'value'}}

# Archive the object into bytes
archived_data = archiver.archive(my_object)
print(f"Archived data (first 50 bytes): {archived_data[:50]}...")

# Unarchive the bytes back into an object
unarchived_object = archiver.unarchive(archived_data)
print(f"Unarchived object: {unarchived_object}")

# Verify round-trip
assert my_object == unarchived_object
print("Archiving and unarchiving successful!")

view raw JSON →