A flexible tool for traversing, filtering, and processing file trees
Project description
Treeverse
Treeverse is a Python tool for traversing and processing file trees using custom code.
Core Logic
- Traverse the file tree recursively, filtering out irrelevant files.
- Process files using custom functions.
- Accumulate processing results from lower directory levels to higher levels.
Treeverse is designed to be flexible, allowing you to plug in your own code for filtering, processing, and accumulation.
Installation
pip install treeverse
Usage
Treeverse operates in three main steps:
-
Traverse and Filter:
treeverse traverse --path /your/project --extensions py,js,ts \ --filter-callbacks your_module:your_filter_function
-
Process Files:
treeverse traverse --path /your/project --extensions py,js,ts \ --payload-callback your_module:your_processing_function > processed_tree.yaml
-
Accumulate Results:
cat processed_tree.yaml | treeverse reduce \ --reduction-callback your_module:your_accumulation_function > results.yaml
You can combine these steps using pipes:
treeverse traverse --path /your/project --extensions py,js,ts \
--payload-callback your_module:your_processing_function | \
treeverse reduce --reduction-callback your_module:your_accumulation_function > results.yaml
Treeverse calls your custom functions, allowing you to implement any logic for filtering, processing, and accumulation.
Example Use Case
Process all code files in a project with a Language Model (LLM) API, and accumulate insights from lower directory levels to higher ones:
treeverse traverse --path /your/project --extensions py,js,ts \
--payload-callback llm_processor:process_file | \
treeverse reduce --reduction-callback llm_processor:accumulate_insights > project_insights.yaml
In this example, llm_processor.py
would contain custom functions for processing files with an LLM API and accumulating insights.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for treeverse-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1022f504d437cc0345b602c1cdae35256d2a8aaa5ec01ef3770ed7ec6ae03815 |
|
MD5 | 97041b4c40c5df82c3bb4d263ade8457 |
|
BLAKE2b-256 | 1f9133e8cc0f109df641eb953e99d6530ba706332ba58024a74223e08e521044 |