tree-interval


Nametree-interval JSON
Version 0.1.34 PyPI version JSON
download
home_pagehttps://github.com/kairos-xx/tree-interval
SummaryA Python package for managing and visualizing interval tree structures
upload_time2025-01-11 04:54:28
maintainerNone
docs_urlNone
authorJoao Lopes
requires_python>=3.11
license MIT License Copyright (c) 2024 Joao Lopes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements pytest pytest rich replit black flake8 build requests toml pyyaml coverage pytest-cov httpimport cloudscraper
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<div align="center">
  <img src="https://github.com/kairos-xx/tree-interval/raw/main/resources/icon_raster.png" alt="Tree Interval Logo" width="150"/>
  <h1>Tree Interval</h1>
  <p><em>A powerful Python package for managing, analyzing, and visualizing tree structures with rich interval-based node positioning</em></p>
  
  <a href="https://replit.com/@kairos/treeinterval">
    <img src="https://github.com/kairos-xx/tree-interval/raw/main/resources/replit.png" alt="Try it on Replit" width="150"/>
  </a>
  
</div>

## ✨ 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

```python
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

```python
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

```bash
pip install tree-interval
```

## 🎯 Core Components

### Position Types
```python
# 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
```python
# Basic ASCII Tree
tree.visualize()

# Rich Pretty Printing
from tree_interval.rich_printer import RichTreePrinter
printer = RichTreePrinter()
printer.print_tree(tree)
```

## 📚 Documentation

- [Core Components](docs/wiki/Core-Components.md)
- [Installation Guide](docs/wiki/Installation.md)
- [Visualization Guide](docs/wiki/Visualization.md)
- [API Reference](docs/API_REFERENCE.md)

## 💡 Use Cases

1. **Code Analysis**
   - Track source positions in AST nodes
   - Locate runtime code execution points
   - Analyze code structure and relationships

2. **Tree Visualization** 
   - Debug tree structures
   - Generate documentation
   - Analyze hierarchical data

3. **Position Tracking**
   - Map source locations
   - Track text positions
   - Handle nested intervals

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

<div align="center">
  <sub>Built with ❤️ by Kairos</sub>
</div>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kairos-xx/tree-interval",
    "name": "tree-interval",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Joao Lopes",
    "author_email": "Joao Lopes <joaoslopes@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/3e/c4/e5b84d9cf8438823a29c30592c2edc7da458d302783f54f3e20d8c44ada6/tree_interval-0.1.34.tar.gz",
    "platform": null,
    "description": "\n<div align=\"center\">\n  <img src=\"https://github.com/kairos-xx/tree-interval/raw/main/resources/icon_raster.png\" alt=\"Tree Interval Logo\" width=\"150\"/>\n  <h1>Tree Interval</h1>\n  <p><em>A powerful Python package for managing, analyzing, and visualizing tree structures with rich interval-based node positioning</em></p>\n  \n  <a href=\"https://replit.com/@kairos/treeinterval\">\n    <img src=\"https://github.com/kairos-xx/tree-interval/raw/main/resources/replit.png\" alt=\"Try it on Replit\" width=\"150\"/>\n  </a>\n  \n</div>\n\n## \u2728 Features\n\n- \ud83d\udd2e **Future Class**: Powerful dynamic attribute handling with context-aware error reporting and smart chain creation\n- \ud83d\udccd **Position-Aware Nodes**: Track code positions with line numbers, column offsets and intervals\n- \ud83c\udf32 **AST Analysis**: Built-in support for Python AST traversal and node location\n- \ud83d\udd0d **Frame Analysis**: Runtime code inspection with frame position tracking\n- \ud83c\udfa8 **Rich Visualization**: Multiple visualization options including ASCII trees and Rich-based pretty printing\n- \ud83d\udcbe **JSON Serialization**: Full support for saving and loading tree structures\n- \ud83d\udd0e **Flexible Node Search**: Parent, child and sibling search with custom predicates\n\n## \ud83d\ude80 Quick Start\n\n### Dynamic Attribute Handling with Future\n\n```python\nfrom tree_interval import Future\n\nclass Nested:\n    def __init__(self):\n        self.__dict__ = {}\n        \n    def __getattr__(self, name):\n        return Future(name, frame=1, instance=self)\n\n# Dynamic attribute chain creation\nobj = Nested()\nobj.a.b.c = 42  # Creates nested structure automatically\nprint(obj.a.b.c)  # 42\n\n# Smart error reporting\nprint(obj.x.y.z)  # Raises detailed error with context\n```\n\n### Tree Operations\n\n```python\nfrom tree_interval import Tree, Leaf, Position\n\n# Create a basic tree\ntree = Tree(\"Example\")\nroot = Leaf(Position(0, 100), \"Root\")\nchild = Leaf(Position(10, 50), \"Child\")\n\ntree.root = root\ntree.add_leaf(child)\n\n# Visualize the tree\ntree.visualize()\n```\n\n## \ud83d\udce6 Installation\n\n```bash\npip install tree-interval\n```\n\n## \ud83c\udfaf Core Components\n\n### Position Types\n```python\n# Basic Position\npos = Position(0, 100)\n\n# Line-Aware Position\npos = Position(0, 100)\npos.lineno = 1\npos.end_lineno = 5\n\n# Column-Aware Position\npos = Position(0, 100)\npos.col_offset = 4\npos.end_col_offset = 8\n```\n\n### Tree Visualization\n```python\n# Basic ASCII Tree\ntree.visualize()\n\n# Rich Pretty Printing\nfrom tree_interval.rich_printer import RichTreePrinter\nprinter = RichTreePrinter()\nprinter.print_tree(tree)\n```\n\n## \ud83d\udcda Documentation\n\n- [Core Components](docs/wiki/Core-Components.md)\n- [Installation Guide](docs/wiki/Installation.md)\n- [Visualization Guide](docs/wiki/Visualization.md)\n- [API Reference](docs/API_REFERENCE.md)\n\n## \ud83d\udca1 Use Cases\n\n1. **Code Analysis**\n   - Track source positions in AST nodes\n   - Locate runtime code execution points\n   - Analyze code structure and relationships\n\n2. **Tree Visualization** \n   - Debug tree structures\n   - Generate documentation\n   - Analyze hierarchical data\n\n3. **Position Tracking**\n   - Map source locations\n   - Track text positions\n   - Handle nested intervals\n\n## \ud83d\udcdd License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n<div align=\"center\">\n  <sub>Built with \u2764\ufe0f by Kairos</sub>\n</div>\n",
    "bugtrack_url": null,
    "license": " MIT License  Copyright (c) 2024 Joao Lopes  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python package for managing and visualizing interval tree structures",
    "version": "0.1.34",
    "project_urls": {
        "Homepage": "https://github.com/kairos-xx/tree-interval",
        "Repository": "https://github.com/kairos-xx/tree-interval.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e83ff653f1894a31dd1984c1f5c42f8a4ee41e7edc4c8bbdc7cfc02dc510b7a",
                "md5": "afaddbaeaa6bc4fd99e0572d5202669f",
                "sha256": "8dc5bfcf6e9138bd0a9571822b789bbfc178f992d0555e819c67085acd38cb0b"
            },
            "downloads": -1,
            "filename": "tree_interval-0.1.34-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "afaddbaeaa6bc4fd99e0572d5202669f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 29039,
            "upload_time": "2025-01-11T04:54:26",
            "upload_time_iso_8601": "2025-01-11T04:54:26.402285Z",
            "url": "https://files.pythonhosted.org/packages/1e/83/ff653f1894a31dd1984c1f5c42f8a4ee41e7edc4c8bbdc7cfc02dc510b7a/tree_interval-0.1.34-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ec4e5b84d9cf8438823a29c30592c2edc7da458d302783f54f3e20d8c44ada6",
                "md5": "1be6e18a4efd65504b6467ef76e90108",
                "sha256": "9217093424eb9a9d6e70413e8c778825c9a2f549c39ba23202a41428ee03ee51"
            },
            "downloads": -1,
            "filename": "tree_interval-0.1.34.tar.gz",
            "has_sig": false,
            "md5_digest": "1be6e18a4efd65504b6467ef76e90108",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 36116,
            "upload_time": "2025-01-11T04:54:28",
            "upload_time_iso_8601": "2025-01-11T04:54:28.621810Z",
            "url": "https://files.pythonhosted.org/packages/3e/c4/e5b84d9cf8438823a29c30592c2edc7da458d302783f54f3e20d8c44ada6/tree_interval-0.1.34.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-11 04:54:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kairos-xx",
    "github_project": "tree-interval",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "replit",
            "specs": [
                [
                    "==",
                    "4.1.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": []
        },
        {
            "name": "flake8",
            "specs": []
        },
        {
            "name": "build",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "toml",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        },
        {
            "name": "coverage",
            "specs": [
                [
                    "==",
                    "7.3.2"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "4.1.0"
                ]
            ]
        },
        {
            "name": "httpimport",
            "specs": [
                [
                    "==",
                    "1.4.0"
                ]
            ]
        },
        {
            "name": "cloudscraper",
            "specs": [
                [
                    "==",
                    "1.2.71"
                ]
            ]
        }
    ],
    "lcname": "tree-interval"
}
        
Elapsed time: 1.25930s