A lightweight Python library and CLI tool for displaying visually structured directory trees with optional emoji and exclusion filters.
Project description
๐๐ณ wintree
This library was born out of the limitations of the default Windows tree command.
wintree is a Python library that displays the directory structure in a tree format for any specified path.
It can be easily used from the command line and supports features like emoji-based visual tree rendering and directory exclusion.
Additionally, it can output the tree structure as JSON, making it suitable for integration with GUI applications.
๐ Usage
๐๏ธ As a Library
import wintree
print(wintree.tree())
# sample output
๐ root: .
โโโ ๐ .gitignore
โโโ ๐ README.md
โโโ ๐ pyproject.toml
โโโ ๐ src/
โ โโโ ๐ assets/
โ โ โโโ ๐ icon.png
โ โ โโโ ๐ splash_android.png
โ โโโ ๐ main.py
โโโ ๐ storage/
โโโ ๐ data/
โโโ ๐ temp/
With arguments:
from wintree import tree
print(tree(root_dir="/path/to/project", use_emoji=True, ignore_dirs=[".git", "__pycache__"], filter_exts=[".py",".txt"]))
| Argument | Type | Description |
|---|---|---|
| root_dir | str | Path to the root directory to start displaying the tree. Default is the current directory "." |
| use_emoji | bool | Whether to use emojis in the tree view. If True, adds icons to folders and files. |
| ignore_dirs | List[str] | List of directory names to exclude from the tree (partial match). Example: [".git", "node_modules"] |
| filter_ext | List[str] | File extensions to include. Example: [".py", "txt"] |
Get or save as JSON
# Get as a dictionary
data = wintree.tree_to_dict(show_meta=True)
# Save as a JSON file
wintree.tree_to_json(root_dir="path/to/project" ,save_path="path/to/project_tree.json")
You can also list absolute paths instead of
import wintree
print(wintree.list_files())
โ๏ธ Usage from CLI
wintree /path/to/project --exclude .git __pycache__
Options
| Option | Description |
|---|---|
| path | Path to the root directory |
| --no-emoji | Disable emoji display |
| --exclude | Specify directory names to exclude (partial match, space-separated) |
| --ext | File extensions to include |
| --no-tree | List absolute paths instead of a tree structure |
| --json-output | Path to save the file hierarchy in |
๐ Features
- Emoji-based tree view for better visibility
- Flexible exclusion of target directories
- Supports Windows/macOS/Linux
- Pure Python, no external dependencies
๐งช For Developers
This library can also be used as a base for directory visualization tools. Integration with GUI tools or IDE plugins is also possible.
๐ License
MIT License
๐ Language
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wintree-0.1.11.tar.gz.
File metadata
- Download URL: wintree-0.1.11.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25f9cdab810e768a722e94c61dec3ade138073438cb7966bd1380093c1784feb
|
|
| MD5 |
a4372eadc5cc12f6a8fbd16ad1d629bc
|
|
| BLAKE2b-256 |
393fc5e8623e37a5bf173f017d358a3d5a630137127c7bd7b1d1048abf9e3c5c
|
File details
Details for the file wintree-0.1.11-py3-none-any.whl.
File metadata
- Download URL: wintree-0.1.11-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.0 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
854419f8c36b324366a23953661806b146425d8c8d21cb86ab28979b6e59e1d2
|
|
| MD5 |
154d14265c7d8a66bc79af0a4738e16a
|
|
| BLAKE2b-256 |
3ef780be3945725e23c12052d27ff00769012e4203eb6dcfd3641f246464116c
|