Treeish
Some functions to help with tree like (json-ish) python structures.
Example Data
>>> data = [
{
"item": "Preliminary Title",
"units": [
{
"item": "Chapter 1",
"caption": "Effect and Application of Laws",
"units": [
{
"item": "Article 1",
"content": 'This Act shall be known as the "Civil Code of the Philippines." (n)\n',
},
{
"item": "Article 2",
"content": "Laws shall take effect after fifteen days following the completion of their publication either in the Official Gazette or in a newspaper of general circulation in the Philippines, unless it is otherwise provided. (1a)\n",
},
],
}
],
}
]
Setter of IDs
>>> from treeish import set_node_ids
>>> set_node_ids(data)
# all nodes in the tree will now have an `id` key, e.g.:
{
"item": "Article 1",
"content": 'This Act shall be known as the "Civil Code of the Philippines." (n)\n',
"id": "1.1.1.1."
},
Getter of Node by ID
>>> from treeish import get_node_id
>>> get_node_id("1.1.1.1.")
{
"item": "Article 1",
"content": 'This Act shall be known as the "Civil Code of the Philippines." (n)\n',
"id": "1.1.1.1."
}
Enables Limited Enumeration Per Layer
>>> raw = [
{"content": "Parent Node 1"},
{
"content": "Parent Node 2",
"units": [
{
"content": "Hello World!",
"units": [
{"content": "Deeply nested content"},
{"content": "Another deeply nested one"},
],
},
{"content": "Another Hello World!"},
],
},
]
>>> from treeish import Layers
>>> Layers.DEFAULT(raw) # note the addition of the `item` key to the raw itemless data
[{'content': 'Parent Node 1', 'item': 'I'},
{'content': 'Parent Node 2',
'units': [{'content': 'Hello World!',
'units': [{'content': 'Deeply nested content', 'item': 1},
{'content': 'Another deeply nested one', 'item': 2}],
'item': 'A'},
{'content': 'Another Hello World!', 'item': 'B'}],
'item': 'II'}]
Fetcher of Values
>>> from treeish import test_fetch_values_from_key
>>> list(test_fetch_values_from_key(data[0]), "item")
[
"Preliminary Title",
"Chapter 1",
"Article 2",
"Article 1",
]
Metadata
Release files for treeish 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treeish-0.0.6.tar.gz | 5.4 kB | Without provenance | Details for treeish-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| treeish-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for treeish-0.0.6-py3-none-any.whl |
Total release size: 11.0 kB
Release files / treeish-0.0.6.tar.gz
| Download URL | treeish-0.0.6.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed50a7e7fd26cd21156f6016d1a09e06896a2f02aadfd74fb4c588f6c1066774
|
|
BLAKE2b-256 checksum How to use checksums |
f7f0c738299a1d29a7ad42805cb675944a5f02b1cedc347f455fe42891fe8f7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.6 Darwin/21.6.0
|
Release files / treeish-0.0.6-py3-none-any.whl
| Download URL | treeish-0.0.6-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f09dba90f0c9415e028f4a33a4f69bf5457bbd554f8b18208b1a2d26e804b849
|
|
BLAKE2b-256 checksum How to use checksums |
9f80ee8735ff75f6b1ce9e5dc14c3f3b9f284ae080f6d58620a802655ace583d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.6 Darwin/21.6.0
|
Security for treeish 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.