mantaray py
Mantaray data structure in Python
Description
With this package you can manipulate and interpret mantaray data via MantarayNode and MantarayFork abstractions.
Installation
- Install using
pip
pip install mantaray_py
Usage
Construct Mantaray
from mantaray_py import MantarayNode, MantarayFork, init_manifest_node, gen_32_bytes
node = init_manifest_node()
address1 = gen_32_bytes()
address2 = gen_32_bytes()
address3 = gen_32_bytes()
address4 = gen_32_bytes()
address5 = gen_32_bytes()
address6 = gen_32_bytes()
path1 = "path1/valami/elso".encode()
path2 = "path1/valami/masodik".encode()
path3 = "path1/valami/masodik.ext".encode()
path4 = "path1/valami".encode()
path5 = "path2".encode()
path6 = "path3/haha".encode()
node.add_fork(path1, address1, { "vmi": "elso" })
node.add_fork(path2, address2)
node.add_fork(path3, address3)
node.add_fork(path4, address4, {"vmi": "negy"})
node.add_fork(path5, address5)
node.add_fork(path6, address6, {"vmi": "haha"})
node.remove_path(path3)
print(node)
Mantaray Storage Operations
from mantaray_py import MantarayNode
node = MantarayNode()
"""
here `reference` parameter is a `Reference` type which can be a 32 or 64 of bytes
and `load_function` is a [load_function: (address: bytes): bytes] typed function
that returns the serialised raw data of a MantarayNode of the given reference. See tests/integration/test_int.py file for reference.
"""
node.load(load_function, reference)
# Manipulate `node` object then save it again
# (...)
# save into the storage with a storage handler [save_function: (data: bytes): Reference]
# See tests/integration/test_int.py file for reference.
reference = node.save(save_function)
How It Works
node binary format
The following describes the format of a node binary format.
┌────────────────────────────────┐
│ obfuscationKey <32 byte> │
├────────────────────────────────┤
│ hash("mantaray:0.1") <31 byte> │
├────────────────────────────────┤
│ refBytesSize <1 byte> │
├────────────────────────────────┤
│ entry <32/64 byte> │
├────────────────────────────────┤
│ forksIndexBytes <32 byte> │
├────────────────────────────────┤
│ ┌────────────────────────────┐ │
│ │ Fork 1 │ │
│ ├────────────────────────────┤ │
│ │ ... │ │
│ ├────────────────────────────┤ │
│ │ Fork N │ │
│ └────────────────────────────┘ │
└────────────────────────────────┘
Fork
┌───────────────────┬───────────────────────┬──────────────────┐
│ nodeType <1 byte> │ prefixLength <1 byte> │ prefix <30 byte> │
├───────────────────┴───────────────────────┴──────────────────┤
│ reference <32/64 bytes> │
│ │
└──────────────────────────────────────────────────────────────┘
Fork with metadata
┌───────────────────┬───────────────────────┬──────────────────┐
│ nodeType <1 byte> │ prefixLength <1 byte> │ prefix <30 byte> │
├───────────────────┴───────────────────────┴──────────────────┤
│ reference <32/64 bytes> │
│ │
├─────────────────────────────┬────────────────────────────────┤
│ metadataBytesSize <2 bytes> │ metadataBytes <varlen> │
├─────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
Documentation: https://Ankvik-Tech-Labs.github.io/mantaray-py/
Source Code: https://github.com/Ankvik-Tech-Labs/mantaray-py
Development
Development
Setup environment
We use Hatch to manage the development environment and production build. Ensure it's installed on your system.
Run unit tests
You can run all the tests with:
hatch run test:test
Format the code
Execute the following command to apply linting and check typing:
hatch run lint:lint-check
Publish a new version
You can bump the version, create a commit and associated tag with one command:
hatch version patch
hatch version minor
hatch version major
Your default Git text editor will open so you can add information about the release.
When you push the tag on GitHub, the workflow will automatically publish it on PyPi and a GitHub release will be created as draft.
Serve the documentation
You can serve the Mkdocs documentation with:
hatch run docs:docs-serve
It'll automatically watch for changes in your code.
License
This project is licensed under the terms of the BSD 3-Clause License license.
Metadata
Release files for mantaray-py 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mantaray_py-0.0.1.tar.gz | 64.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mantaray_py-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 82.8 kB
Release files / mantaray_py-0.0.1.tar.gz
| Download URL | mantaray_py-0.0.1.tar.gz |
|---|---|
| Size | 64.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d97770a920015adcad07b27b25ba2cbd33089a0d32afafa32aeaf2afec79c9e2
|
|
BLAKE2b-256 checksum How to use checksums |
76eaa28553e09490ec4a3cbc96224ea571a85f50abef190af87b5a0c65ee3195
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|
Release files / mantaray_py-0.0.1-py3-none-any.whl
| Download URL | mantaray_py-0.0.1-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6892bc88d16795ea5d9564c3cf5d57cf5aebc5d28af2912a496742518a17dccd
|
|
BLAKE2b-256 checksum How to use checksums |
53fdba85f1a53107f26ce6bfd9658b58f61bb83931e8c369a594f02609aa5e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|