Skip to main content

Create directory and file structures from tree-like text representations

Project description

📁 Tree Creator

PyPI Python Versions License

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.1.3.tar.gz (10.8 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.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tree_creator-1.1.3.tar.gz
  • Upload date:
  • Size: 10.8 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.1.3.tar.gz
Algorithm Hash digest
SHA256 46d2d3181b3bca6a8fe1a3bf99faecdd5db79d549a72d229fd0d35e53bccc887
MD5 3b0e2e9f73231053febe79b8f3e29ecc
BLAKE2b-256 fac1ae5d1038f95caf7862c0ea83e8260b0d3f181c3d1a7e6f49c1344ea60999

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tree_creator-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1ed86b2a5d35ff1b56ebd66be4866fce8d8fd7543b50f303e1417a08480563
MD5 fd1fc3455de38725c63af1f568813067
BLAKE2b-256 f592b78cb9834f0c0862f01b6a47901aebc78b81eaf18a9afa045eb3f2369c4e

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