Skip to main content

Create directory and file structures from tree-like text representations

Project description

📁 Tree Creator

Create directory and file structures from tree-like text representations — just like the output of the tree command.

✨ Features

  • Parse text-based tree structures and generate corresponding directories and files.
  • Dry-run support (simulate without creating files).
  • CLI and API support.
  • Helpful logging for debugging and auditing.
  • Version managed centrally via _version.py.
  • Zero external dependencies.

📦 Installation

pip install tree-creator

or (for development):

git clone https://github.com/jack-low/tree-creator
cd tree-creator
pip install -e ".[dev]"

🚀 Usage

✨ Example (Python API)

from tree_creator import TreeCreator

tree_text = '''
project/
├── src/
│   ├── main.py
│   └── utils.py
└── README.md
'''

creator = TreeCreator()
creator.create_from_text(tree_text, base_dir='./my_project')

💻 CLI

tree-creator tree.txt --base-dir ./my_project
tree-creator tree.txt --dry-run
echo "dir/\n└── file.txt" | tree-creator -

🧪 Example using Here Document (EOF)

tree-creator -b ./output-dir -d - <<EOF
myapp/
├── index.html
└── static/
    └── style.css
EOF
  • -d enables dry-run mode
  • -b ./output-dir sets the output base directory
  • - reads from stdin

Options

Option Description
-b, --base-dir Target base directory (default: .)
-e, --encoding Encoding for input file (default: utf-8)
-d, --dry-run Simulate without file creation
-v, --verbose Verbose log output
-V, --version Display version

📄 Tree Format

A valid tree structure should follow conventions like:

project/
├── src/
│   ├── main.py
│   └── utils.py
└── README.md
  • Directories end with /
  • Use characters like ├──, └──,

🧪 Development

pip install -e ".[dev]"
pytest
black .
flake8 .
mypy tree_creator

📜 License

MIT License © Jack3Low

🔗 Links

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

tree_creator-1.0.62.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

tree_creator-1.0.62-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file tree_creator-1.0.62.tar.gz.

File metadata

  • Download URL: tree_creator-1.0.62.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tree_creator-1.0.62.tar.gz
Algorithm Hash digest
SHA256 e0e187420d2ce5f7d53537cf2e43b7a8d9aa42b29976ac442f2d85dd98715523
MD5 b4dfe3932897b7a5e0f5bf801239481b
BLAKE2b-256 2287d1eb32b42274bccd9cddcdc4b89cc1ef3bffe687404bec9b4d13243cd0ca

See more details on using hashes here.

File details

Details for the file tree_creator-1.0.62-py3-none-any.whl.

File metadata

  • Download URL: tree_creator-1.0.62-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tree_creator-1.0.62-py3-none-any.whl
Algorithm Hash digest
SHA256 035e788300ca9506a0a75573bdfb7a433577aa3317fddcfe225681019ef3f0ca
MD5 4cfae0724730972323c34a66929b76f8
BLAKE2b-256 d9373aed7d99b9a57e047f2ac9e6442e32b95b86eeb62d19f3afd4923a58e753

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