Skip to main content

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

Release files for treescaffold 1.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for treescaffold 1.4.4
File Size Uploaded
treescaffold-1.4.4.tar.gz 17.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for treescaffold 1.4.4
File Interpreter ABI Platform
treescaffold-1.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / treescaffold-1.4.4.tar.gz

Download URL treescaffold-1.4.4.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
88d207059e65cca9108964e390453426767fa56abaf6f5014b32be2f7cfc3a15
BLAKE2b-256 checksum
How to use checksums
b0fd344b599b7897540879b8faca76a11b577d936c57b826707db5362327ec62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / treescaffold-1.4.4-py3-none-any.whl

Download URL treescaffold-1.4.4-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22138b254ba91263d11905a35ce4db2bca32f8041c2e42de6faabb163540a041
BLAKE2b-256 checksum
How to use checksums
8d189cac953c97a40a65ef9f417c54bffb183299b77049358e59d1f71a0e81a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

1.4.4 This release

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page