Python Syntax Tree Printer
This project is a Python-based syntax tree printer utility that reads a source code file, guesses the language based on the file extension, and prints the syntax tree using tree-sitter.
Features
- Supports Rust and Python source files
- Prints detailed syntax tree nodes
- Uses Tree-sitter for parsing
- Syntax highlighting for parse trees
- Lists all node IDs and their corresponding names for a language
Requirements
- Python 3.10+
- pip
Installation
-
Clone this repository:
git clone https://github.com/yourusername/python-syntax-tree-printer.git cd python-syntax-tree-printer -
Install the required dependencies:
pip install .
Usage
-
Run the program with a file path as an argument to print the syntax tree:
tsutil <file-path> -
Run the program with the
--highlightflag to print the syntax tree with syntax highlighting:tsutil <file-path> --highlight -
Run the program with the
--list-idsflag to list all node IDs and their corresponding names for the language:tsutil <file-path> --list-ids
Example
To print the syntax tree of a Python source file:
tsutil example/simple_addition.py
To print the syntax tree with syntax highlighting:
tsutil example/simple_addition.py --highlight
To list all node IDs and their corresponding names for a Python source file:
tsutil example/simple_addition.py --list-ids
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Acknowledgements
- Tree-sitter for the parsing library
- py-tree-sitter for the Python bindings
- termcolor for terminal colorization
Metadata
Release files for tsutil-py 0.1.0
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 |
|---|---|---|---|---|
| tsutil_py-0.1.0.tar.gz | 2.6 kB | Without provenance | Details for tsutil_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tsutil_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tsutil_py-0.1.0-py3-none-any.whl |
Total release size: 6.4 kB
Release files / tsutil_py-0.1.0.tar.gz
| Download URL | tsutil_py-0.1.0.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76f9daf3786317a7c03c34825c1e9db5f5225d1e966f4c6b643ae7eb86695909
|
|
BLAKE2b-256 checksum How to use checksums |
cd8ba0ef35391cddc110b67268a78688df4c6e93da38c04ad25dbc7c01b8ac22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.16.1 CPython/3.11.5 Linux/5.15.0-91-generic
|
Release files / tsutil_py-0.1.0-py3-none-any.whl
| Download URL | tsutil_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c05a8a5808b8ca2a76269c228154a4de26e7d8ea44e4ec831a8b13fa676d1c86
|
|
BLAKE2b-256 checksum How to use checksums |
20f1829f1b96bf448aa0c659c1e07da18ef68288cd063f12dcbcf1be8bc8da7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.16.1 CPython/3.11.5 Linux/5.15.0-91-generic
|
Security for tsutil-py 0.1.0
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.