Skip to main content

Generate folder structures from various input formats (tree, YAML, simple indentation)

Project description

treescaffold (foldertree)

PyPI codecov License: MIT

A Python tool to generate folder structures from tree-like format.

Features

  • Multiple Input Formats: Supports tree-like structures, YAML, and simple indentation
  • Auto-detection: Automatically detects input format
  • Comment Support: Adds comments to generated files based on file extensions
  • Python Package Detection: Automatically creates __init__.py files in Python packages
  • Smart Skipping: Skips common files like __pycache__, .git, node_modules, etc.
  • Dry Run Mode: Preview what will be created without actual file creation
  • Flexible Output: Specify custom output directories

Installation

Directly from PyPI:

pip install treescaffold

Or from GitHub:

git clone https://github.com/sree-sphere/foldertree.git
cd foldertree
pip install -e .

Usage

Command Line

# From a structure file
treescaffold -f structure.tree
# (alias: `foldertree -f structure.tree`)


# From stdin
echo "api/
  routes.py
core/
  classifier.py" | treescaffold
# (alias: `foldertree`)

# Specify output directory (recommended)
treescaffold -f structure.tree -o project_output
# (alias: `foldertree -f structure.tree -o project_output`)

# Dry run (preview only)
treescaffold -f structure.tree --dry-run
# (alias: `foldertree -f structure.tree --dry-run`)

# Force specific format
treescaffold -f structure.yaml --format yaml
# (alias: `foldertree -f structure.yaml --format yaml`)

Python

from foldertree import TreeParser, TreeGenerator

# Parse structure
parser = TreeParser()
tree = parser.parse("""
api/
  routes.py    # FastAPI endpoints
core/
  classifier.py  # ML model
""")

# Generate structure
generator = TreeGenerator("./output")
result = generator.generate(tree)
print(f"Created {len(result['created_files'])} files")

Input Formats

  • Tree Format (with symbols)
├── api/
│   ├── __init__.py
│   └── routes.py
├── core/
│   ├── __init__.py
│   └── classifier.py
├── data/
│   ├── chunks_head/
│   └── highlight.json
└── main.py
  • Simple Indentation
api/
  routes.py                  # FastAPI endpoints
core/
  classifier.py              # ML model
main.py
  • YAML Format
structure:
  api:
    - routes.py
    - __init__.py
  core:
    - classifier.py
    - __init__.py
  main.py: null

Comment Support

The tool automatically adds appropriate comments to files based on their extensions:

  • .py files: # Comment
  • .js/.ts files: // Comment
  • .css files: /* Comment */
  • .html/.xml files:
  • And many more...

Smart Features

Automatic __init__.py Creation

When directories contain .py files, __init__.py is automatically created to make them proper Python packages.

Intelligent Skipping

Automatically skips common files and directories:

  • __pycache__
  • .git
  • node_modules
  • .env
  • Build/dist directories
  • And more...

Options

  • -f, --file: Input file containing folder structure
  • -o, --output: Output directory (default: current directory)
  • --format: Force input format (tree, yaml, simple, auto)
  • --dry-run: Show what would be created without creating files
  • -v, --verbose: Verbose output
  • --version: Show version

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

treescaffold-1.4.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

treescaffold-1.4.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file treescaffold-1.4.1.tar.gz.

File metadata

  • Download URL: treescaffold-1.4.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for treescaffold-1.4.1.tar.gz
Algorithm Hash digest
SHA256 4f01d8fd4323ea590aab137621147675ca8fd0f6e098508c073e7fdf560c5ddc
MD5 2ae8391f92fb3c5ac2657701c9978a77
BLAKE2b-256 5943fdcdfd0bde7802fcea3618be485995dd723b880d0a7ba69071ae834109e5

See more details on using hashes here.

File details

Details for the file treescaffold-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: treescaffold-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for treescaffold-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5ccd1a5da4147d3eb4a5fc781ff4a2144a93717739b4fea6eaee7220ae7aab8
MD5 568c7354e872ccc70f6e5181c6bb71df
BLAKE2b-256 d742d89216cc5544bab421fffe811b9a27fc063758db1de992afcf27bf9b4e7d

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