Skip to main content

Python NSKeyedArchiver explorer, archiver, and dearchiver

Project description

Mentalics

[!WARNING]
This library is not stable yet.

mentalics is designed primarily to read, write, and analyze NSKeyedArchiver-generated archives as Python object graphs. It is designed to reflect the NSCoder interface, handle circular references, and efficiently work through unknown classes and files.

Usage

Exploring an unknown archive (not stable):

from mentalics import Explorer

with open("my.plist", "rb") as file:
    explorer = Explorer(file)

print(explorer._classes)

Decoding a known archive:

from mentalics import Unarchiver, NSCoding
from dataclasses import dataclass


@dataclass
class MyClass(NSCoding):
    my_attr: str

    def __init_from_archive__(self, decoder) -> "NSCoding":
        my_attr = decoder.decode("myAttr")
        return self.__init__(my_attr)

    def encode_archive(self, encoder) -> None:
        encoder.encode(self.my_attr, for_key="myAttr")


with open("my.plist", "rb") as file:
    dearchiver = Unarchiver(file)
    dearchiver.set_class(MyClass, "MyClass")
    
root = dearchiver.decode()
print(root)

Why mentalics?

There are many other libraries for parsing plists and archives: plistlib and bplist-python (plists, not archives), bpylist and bpylist2, plistutils, ccl-bplist, and probably others.

However, there is mismatched support for desirable features:

  • Handling circular references (ccl-bplist)
  • NSCoder/NSCoding-like interface (bpylist, bpylist2)
  • Simple handling of NSValues (none)
  • Exploring archives with unknown structure (ccl-bplist)
  • Generating code for classes from archives (none)

All of these are either a part of mentalics or a planned feature.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mentalics-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mentalics-0.2.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file mentalics-0.2.0.tar.gz.

File metadata

  • Download URL: mentalics-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for mentalics-0.2.0.tar.gz
Algorithm Hash digest
SHA256 be8621c1ee246162446b43f0a4e5ae11b25bb7a366b96d93d1ace5c4d98ca767
MD5 6782d0b1442a2b7d0f729d02cfead12f
BLAKE2b-256 afde0cc0c93f502c175a9ae20843022819f5826957b25598898bbebc9efecbce

See more details on using hashes here.

File details

Details for the file mentalics-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mentalics-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.12.0 Darwin/23.2.0

File hashes

Hashes for mentalics-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c99986d9e3aae63e83909458becb6943f24dacb87d6bbc7224b3e17093192e46
MD5 72de0d8a8e3f9f4293f7c967c2befac3
BLAKE2b-256 5ab2ea9bc16192404bb69ef26f6bb3c721d4fcc49237723092cfed166b752894

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page