Skip to main content

A human-readable and secure XML-based alternative to pickle.

Project description

License PyPi File Extension

pklxml

pklxml, short for Python Pickle Extensible Markup Language Library, is a Python module and as a human-readable alternative to Pickle. Instead of saving data as a binary .pkl file, it saves data as an XML-based file called .pklxml. This makes it a lot more safer. The module uses the LXML module to parse .pklxml (XML) files.

The reason why I wanted to make this module is so that we (as humans) can see what has been actually saved. Currently, I have to open .pkl files with Qt Creator to decode the binary and usually, with (no) success.

Example programme

List and dictionary example code

from pklxml import dump, load

data = {'name': 'Alice', 'age': 30}
dump(data, 'data.pklxml')

try:
  data = load('data.pklxml')
  print(data)
except OSError:
  data = {}

Class example code

from pklxml import dump, load

# Define a simple class (normally this would be in a separate module)
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

# Register the class somewhere importable if needed
# For now, let's pretend it's in 'example_class' for deserialization
Person.__module__ = "examples.example_class"

# Create an instance
alice = Person("Alice", 30)

# Serialize to XML
pklxml.dump(alice, "examples/output_basic.pklxml")

# Deserialize from XML
try:
    restored = pklxml.load("examples/output_basic.pklxml")
    print(f"Restored: {restored.__class__.__name__}({restored.name}, {restored.age})")
except OSError as e:
    print("Failed to load .pklxml file:", e)

Contribute

Contribute to this repository if you can! Star my repository! Thanks!

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

pklxml-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

pklxml-0.2.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pklxml-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pklxml-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f0be4f0e7b38a8c138727f4cc5b486795c1ad53e7078606b52c154ad7454dd14
MD5 70e03d0071c53783e47bb1b43450a8c7
BLAKE2b-256 5ea89210029c6c11cecda59a1d17be2339a2b4167291d31e90b5be091e69893a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pklxml-0.2.0.tar.gz:

Publisher: python-publish.yml on RAPTOR7762/pklxml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pklxml-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pklxml-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 820bd1012914b7551cd7b9fc907500b48fa6623303a12d34234eef827b057a4c
MD5 34127843842fa9c3d10d13c1732bb8b7
BLAKE2b-256 64a880dbaefe8e15d0751240a0fc818f19336acafc0d9b898fd099fc46dcd3e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pklxml-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on RAPTOR7762/pklxml

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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