Skip to main content

Generate directory tree diagrams from the command line

Project description

Pyletree

Pyletree is a simple and fast CLI tool to generate directory tree diagrams.

Installation

pip install pyletree

Usage

pyletree [ROOT_DIR]

If no directory is provided, the current directory is used:

pyletree

Show help:

pyletree -h

Options

General

  • -h, --help Show help message
  • -v, --version Show version

Modes

  • -d, --dir-only Show directories only
  • -f, --files-only Show files only

Ordering

  • -df, --dirs-first List directories before files
  • -ff, --files-first List files before directories

Alphabetical order is always applied as base sorting.

Display

  • -n, --no-pipes Remove vertical pipes between branches

Ignoring

  • -i, --ignore PATTERN [PATTERN ...] Ignore files/directories
  • -gi, --gitignore Respect .gitignore rules

Depth

  • -dl, --depth-level N Limit depth

Examples

Basic:

pyletree

Directories first:

pyletree . -df

Files only:

pyletree . -f

Limit depth:

pyletree . -dl 2

Ignore entries:

pyletree . -i node_modules dist .git

Use .gitignore:

pyletree . -gi

No pipes mode:

pyletree . -n

Python API

You can also use Pyletree programmatically in your own Python code using the FileTree class. It returns an iterable that can also be printed directly:

from pyletree import FileTree

# Create a tree for the current directory
tree = FileTree()

# Print the tree directly
print(tree)

# Or iterate over its lines
for line in tree:
    print(line)

# You can configure it with the same options of the CLI
custom_tree = FileTree(
    root_dir='src/',
    dir_only=True,
    ignore=['__pycache__']
)
print(custom_tree)

Sample Output

Default

project/
│
├── src/
│   ├── main.py
│   └── utils.py
│
├── tests/
│   └── test_main.py
│
└── README.md

No pipes (-n)

project/
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
└── README.md

Features

  • Clean and readable tree output
  • .gitignore support (it does not ignore either the .git directory or the .gitignore file; if you want to ignore them, add them to the ignore patterns)
  • Custom ignore patterns
  • Depth limiting
  • Flexible sorting
  • Optional compact mode (--no-pipes)

Release History

1.1.0

  • Removed -o --output-file option
  • Added FileTree class for programmatic usage in Python scripts.

1.0.0

  • Initial release

Authors

Davi Reis Furtado

Original RP Tree Author: Leodanis Pozo Ramos

License

Pyletree is distributed under the MIT license. See LICENSE for more information.

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

pyletree-1.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

pyletree-1.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pyletree-1.1.0.tar.gz.

File metadata

  • Download URL: pyletree-1.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyletree-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2828983c064ff1aed3151a5858508da1bed4e825d9ff48612966b790e377dba1
MD5 dd4c776cd940d9f54960a4e4298bc1e3
BLAKE2b-256 f8b7e6cd530d3524bedd44a6b809b7c785fe1f2845700c8884981a4a5159a64b

See more details on using hashes here.

File details

Details for the file pyletree-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyletree-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyletree-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec1e18d66d7d9de06a0406b09ffcceacc328aa32197543aa2ab78d956df38028
MD5 639de1d690cf68612a748f9257952ff7
BLAKE2b-256 60d38e0effd625bdfa192281d20f04372d7968156f2320ee6508a030efff6b36

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