Skip to main content

A lightweight Python library and CLI tool for displaying visually structured directory trees with optional emoji and exclusion filters.

Project description

๐Ÿ“๐ŸŒณ wintree

PyPI Downloads

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.

๐Ÿ”‹ Install

pip install wintree

๐Ÿš€ 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 file paths vertically as relative or absolute paths from the root directory, instead of using a tree structure.

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
--abs Output absolute file paths
--json-output Path to save the file hierarchy in
--show-meta Include timestamp and file size in JSON output

๐Ÿ“Œ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wintree-0.1.15.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wintree-0.1.15-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file wintree-0.1.15.tar.gz.

File metadata

  • Download URL: wintree-0.1.15.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.0 Windows/11

File hashes

Hashes for wintree-0.1.15.tar.gz
Algorithm Hash digest
SHA256 b5a26d52cd6437dc8b3749236913b61bf80d435b6c38916dc8d4659ec9c5c5ba
MD5 cfc4eac4bd69b26730fe5ee6d4722476
BLAKE2b-256 26c7e262b3c7de67daf7e2702536cb1bc95645611f0362acc627618483c76cae

See more details on using hashes here.

File details

Details for the file wintree-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: wintree-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.0 Windows/11

File hashes

Hashes for wintree-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 1f631cb9b9c2b3c3f0bd4e1ce90d37a83296b36dd37ba876d0924f1b757024f7
MD5 07309cfb9ac57e03123b77d532bb6de0
BLAKE2b-256 e41bd5ece880178e34885233bc1f4ffbf958a2f90e5cc0571618298572fc6c92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page