Skip to main content

Python bindings to the katsuba Rust libraries

Project description

Katsuba

Python bindings to the Katsuba libraries.

Error handling

Most errors are represented either as native Python exceptions where it makes sense, or as a katsuba.KatsubaError for custom errors from the Rust side.

Bindings

katsuba.op

Bindings to core functionality from the katsuba-object-property crate.

from katsuba.op import *
from katsuba.utils import string_id

# Open a type list from file system
type_list = TypeList.open("types.json")

# Configure serializer options
opts = SerializerOptions()
opts.flags |= STATEFUL_FLAGS
opts.shallow = False

# Construct the serializer
ser = Serializer(opts, type_list)

# Deserialize a file
with open("TemplateManifest.xml", "rb") as f:
    manifest = f.read()
    assert manifest[:4] == b"BINd"

manifest = ser.deserialize(manifest[4:])

# Make sure we deserialized the right object:
assert manifest.type_hash == string_id("class TemplateManifest")

# Iterate the templates in the resulting object:
for location in manifest["m_serializedTemplates"]:
    print(f"Template {location['m_id']} at {location['m_filename']}")

katsuba.wad

Bindings to core functionality from the katsuba-wad crate.

from katsuba.op import Serializer
from katsuba.wad import Archive

# See `katsuba.op` above.
s = Serializer(...)

# Open an archive memory-mapped:
a = Archive.mmap("/path/to/Root.wad")

print(f"{len(a)} files in archive!")

# Deserialize a file out of the given archive:
if "TemplateManifest.xml" in a:
    a.deserialize("TemplateManifest.xml", s)

# Iterate over files in the archive and get their contents:
for path in a:
    data = a[path]

# With a glob pattern for filtering files:
for path in a.iter_glob("ObjectData/**/*.xml"):
    data = a[path]

katsuba.utils

Bindings to useful components from the katsuba-utils crate.

For the time being, this features the hash functions djb2 and string_id.

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

katsuba-0.2.2.tar.gz (60.2 kB view details)

Uploaded Source

Built Distributions

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

katsuba-0.2.2-cp310-abi3-win_amd64.whl (697.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

katsuba-0.2.2-cp310-abi3-win32.whl (641.6 kB view details)

Uploaded CPython 3.10+Windows x86

katsuba-0.2.2-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (826.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.5+ x86-64

katsuba-0.2.2-cp310-abi3-macosx_11_0_arm64.whl (687.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

katsuba-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl (781.0 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file katsuba-0.2.2.tar.gz.

File metadata

  • Download URL: katsuba-0.2.2.tar.gz
  • Upload date:
  • Size: 60.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.2

File hashes

Hashes for katsuba-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9008abdfcf18e886a65cb6d14ecda3f62fb2cc928fde49624fff30ff23ffc0b1
MD5 917451c7cffd9db6fbfc8ee5397781dd
BLAKE2b-256 d200499f80284031296eba692ed709ec1bbaabaa1a78a024388a9408ed0000a8

See more details on using hashes here.

File details

Details for the file katsuba-0.2.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: katsuba-0.2.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 697.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.2

File hashes

Hashes for katsuba-0.2.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5ea4b8d55bd90d2de01c8b854d3c980cf34f025f7abd17a23bd7845e3db33ba8
MD5 e758929c0c51028d18ba45abc59919a8
BLAKE2b-256 424cc5ee991d19fc9c78cd20ba8b01fa88dd2e000f77320554e40492c1405d88

See more details on using hashes here.

File details

Details for the file katsuba-0.2.2-cp310-abi3-win32.whl.

File metadata

  • Download URL: katsuba-0.2.2-cp310-abi3-win32.whl
  • Upload date:
  • Size: 641.6 kB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.2

File hashes

Hashes for katsuba-0.2.2-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 5d556fc7aa021497c7cac7a03900267548e8fd728848abd2674a689ea11dfb9c
MD5 ea4ea6b29bb6cf424413cbe9308ac0cf
BLAKE2b-256 823e1afca5f260911b7d4beb7caed9a8ca1c74cefdd037c73c631a87ac99cc52

See more details on using hashes here.

File details

Details for the file katsuba-0.2.2-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for katsuba-0.2.2-cp310-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 08fcc80009f4602014a72d26e066c2ab5327ab90b306ebf4c0befc6f0fcbbbb9
MD5 e5b8e5d86973450cf74c6ff96531131c
BLAKE2b-256 ef11d90de9d657b1f4f75d786655cf179b6d4b0779914f01da36d0fd4034c167

See more details on using hashes here.

File details

Details for the file katsuba-0.2.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for katsuba-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eaa6477d85c0889c80e9ec83d526050a73e20c75ab0f2ee7d05d56879612f226
MD5 622bae88b4dc7a79d5c372a7ae76bf06
BLAKE2b-256 03612595cc5adecf3e5c93f1bd33e768d6551f980ec240f51dfd19a02fc33cf4

See more details on using hashes here.

File details

Details for the file katsuba-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for katsuba-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a30336378a8e1a85ce248ea8ac553220d5056687e06004fdb8e2dad4cb87c3b1
MD5 3887175350eddaa11f661c1da40bc26f
BLAKE2b-256 f4c73e12f00cfeb543607b74d16b31a6c5a10e61b96cba0cbb4a645b388724d1

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