Treeverse
Treeverse is a Python tool for traversing, processing, and accumulating data from file trees using custom code.
Installation
pip install treeverse
Usage
Treeverse operates in three main steps:
- Build: Traverse the directory and build the file tree
- Process: Apply custom processing to each node
- Accumulate: Aggregate data from child nodes to parent nodes
1. Build the tree
treeverse build -p /path/to/your/project -e py -e yaml \
-c your_module:your_filter_function -o tree.yaml
Options:
-p, --path: Specify the path to traverse (default is current directory)-e, --extensions: Specify file extensions to include (can be used multiple times)-c, --callback: Path to filter callback functions (can be used multiple times)-o, --output: Output file (default: tree.yaml)--write-to-stream: Write output to stdout instead of a file
2. Process the tree
treeverse process -i tree.yaml -c your_module:your_processing_function -o processed_tree.yaml
Options:
-i, --input: Input file (default: tree.yaml)-c, --callback: Path to the processing function-o, --output: Output file (default: processed_tree.yaml)--read-from-stream: Read input from stdin instead of a file--write-to-stream: Write output to stdout instead of a file
3. Accumulate results
treeverse accumulate -i processed_tree.yaml -c your_module:your_accumulation_function -o final_result.yaml
Options:
-i, --input: Input file (default: processed_tree.yaml)-c, --callback: Path to the accumulation function-o, --output: Output file (default: accumulated_tree.yaml)--read-from-stream: Read input from stdin instead of a file--write-to-stream: Write output to stdout instead of a file
Example Use Case
Process all Python and YAML files in a project, analyze them, and accumulate results:
treeverse build -p ~/path/to/your/project -e py -e yaml -o tree.yaml
treeverse process -i tree.yaml -c ~/path/to/your/tools.py:analyze_file -o processed_tree.yaml
treeverse accumulate -i processed_tree.yaml -c ~/path/to/your/tools.py:accumulate_results -o final_analysis.yaml
To use streaming for the entire pipeline:
treeverse build -p ~/path/to/your/project -e py -e yaml --write-to-stream | \
treeverse process -c ~/path/to/your/tools.py:analyze_file --read-from-stream --write-to-stream | \
treeverse accumulate -c ~/path/to/your/tools.py:accumulate_results --read-from-stream > final_analysis.yaml
In this example, tools.py would contain custom analyze_file and accumulate_results functions.
Reference Implementations
For examples of callable functions that can be used with Treeverse, check the simple_callbacks.py file in the project repository. This file contains reference implementations for filtering, processing, and accumulation functions.
Metadata
Release files for treeverse 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| treeverse-0.2.1.tar.gz | 17.6 kB | Without provenance | Details for treeverse-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| treeverse-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for treeverse-0.2.1-py3-none-any.whl |
Total release size: 36.8 kB
Release files / treeverse-0.2.1.tar.gz
| Download URL | treeverse-0.2.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e228608b35f26c2ddd3a541563cb97b5c98f6d7922c33c519b84b32ed13cca20
|
|
BLAKE2b-256 checksum How to use checksums |
f99ab0844fa5ddbf3d3ff0ba49b945e48ba7b31f08fc857ef6d1f70dca577028
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.6 Darwin/23.4.0
|
Release files / treeverse-0.2.1-py3-none-any.whl
| Download URL | treeverse-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b66ba9a3cdb6b81dc58e9115db0fd87e0d81ba1233c1de6e71743f257a5231d5
|
|
BLAKE2b-256 checksum How to use checksums |
6280f9c65b0e57ef4133369f32c8b04eadb59070d2a5cae5285e6f52bc8dd492
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.6 Darwin/23.4.0
|
Security for treeverse 0.2.1
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.