Tree Interval
A powerful Python package for managing, analyzing, and visualizing tree structures with rich interval-based node positioning
✨ Features
- 🔮 Future Class: Powerful dynamic attribute handling with context-aware error reporting and smart chain creation
- 📍 Position-Aware Nodes: Track code positions with line numbers, column offsets and intervals
- 🌲 AST Analysis: Built-in support for Python AST traversal and node location
- 🔍 Frame Analysis: Runtime code inspection with frame position tracking
- 🎨 Rich Visualization: Multiple visualization options including ASCII trees and Rich-based pretty printing
- 💾 JSON Serialization: Full support for saving and loading tree structures
- 🔎 Flexible Node Search: Parent, child and sibling search with custom predicates
🚀 Quick Start
Dynamic Attribute Handling with Future
from tree_interval import Future
class Nested:
def __init__(self):
self.__dict__ = {}
def __getattr__(self, name):
return Future(name, frame=1, instance=self)
# Dynamic attribute chain creation
obj = Nested()
obj.a.b.c = 42 # Creates nested structure automatically
print(obj.a.b.c) # 42
# Smart error reporting
print(obj.x.y.z) # Raises detailed error with context
Tree Operations
from tree_interval import Tree, Leaf, Position
# Create a basic tree
tree = Tree("Example")
root = Leaf(Position(0, 100), "Root")
child = Leaf(Position(10, 50), "Child")
tree.root = root
tree.add_leaf(child)
# Visualize the tree
tree.visualize()
📦 Installation
pip install tree-interval
🎯 Core Components
Position Types
# Basic Position
pos = Position(0, 100)
# Line-Aware Position
pos = Position(0, 100)
pos.lineno = 1
pos.end_lineno = 5
# Column-Aware Position
pos = Position(0, 100)
pos.col_offset = 4
pos.end_col_offset = 8
Tree Visualization
# Basic ASCII Tree
tree.visualize()
# Rich Pretty Printing
from tree_interval.rich_printer import RichTreePrinter
printer = RichTreePrinter()
printer.print_tree(tree)
📚 Documentation
💡 Use Cases
-
Code Analysis
- Track source positions in AST nodes
- Locate runtime code execution points
- Analyze code structure and relationships
-
Tree Visualization
- Debug tree structures
- Generate documentation
- Analyze hierarchical data
-
Position Tracking
- Map source locations
- Track text positions
- Handle nested intervals
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for tree-interval 0.1.34
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 |
|---|---|---|---|---|
| tree_interval-0.1.34.tar.gz | 36.1 kB | Without provenance | Details for tree_interval-0.1.34.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tree_interval-0.1.34-py3-none-any.whl | Python 3 | none | any | Details for tree_interval-0.1.34-py3-none-any.whl |
Total release size: 65.2 kB
Release files / tree_interval-0.1.34.tar.gz
| Download URL | tree_interval-0.1.34.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9217093424eb9a9d6e70413e8c778825c9a2f549c39ba23202a41428ee03ee51
|
|
BLAKE2b-256 checksum How to use checksums |
3ec4e5b84d9cf8438823a29c30592c2edc7da458d302783f54f3e20d8c44ada6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / tree_interval-0.1.34-py3-none-any.whl
| Download URL | tree_interval-0.1.34-py3-none-any.whl |
|---|---|
| Size | 29.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dc5bfcf6e9138bd0a9571822b789bbfc178f992d0555e819c67085acd38cb0b
|
|
BLAKE2b-256 checksum How to use checksums |
1e83ff653f1894a31dd1984c1f5c42f8a4ee41e7edc4c8bbdc7cfc02dc510b7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Security for tree-interval 0.1.34
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.