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.5.tar.gz (9.7 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.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tree_creator-1.0.5.tar.gz
  • Upload date:
  • Size: 9.7 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.5.tar.gz
Algorithm Hash digest
SHA256 61f22fe77fba353866ddcd40eb811caa0ddb64fac036076057da70fddbbe6315
MD5 c33cd462d70b58ebf8d991b5654dac6c
BLAKE2b-256 d8d38ce8e3f67d055c9adfdb752b2bd8651547a13840acabd576458529cd5176

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tree_creator-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0d5e9762968a5eeff1c64baec6cadf619e3da6448acf58fe3e7cd96d700929ae
MD5 0a2ee1cb6190add72c949961f4c7455d
BLAKE2b-256 875395c0cb92c5eba23751840219a4febeeb74406a93ccac155b68b3ab6d7ec8

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