Treefile
Treefile is a Python package designed to generate file trees based on a plaintext configuration described in a .treefile file. It allows you to create complex directory structures with files and directories, optionally including virtual environments.
This project aims to simplify the process of setting up projects or generating boilerplate code by defining the structure in a simple text file.
Table of Contents
- Installation
- Usage
- Command Line Arguments
- Features
- Configuration File
- Context Menu and File Icon Integration
- Contributing
- License
Installation
To install Treefile, use pip:
pip install treefile
Alternatively, you can clone the repository and install it manually in an editable mode (Ensure Python 3.6 or later installed):
git clone https://github.com/BenevolenceMessiah/treefile.git
cd treefile
pip install -e .
Usage
Treefile reads a .treefile configuration file and generates the corresponding directory structure.
Basic Usage
- Create a
.treefilefile with your desired structure:
project/
src/
main.py
README.md
- Run Treefile:
treefile --file project.treefile --output output_dir
- The files and directories will be created in the specified output directory.
Sample .treefile File Showing 'Tree Branches'
Lines can also include UTF-8 “tree branch” characters (e.g., ├──, └──), though this is optional. Indentation (preferably using 4 spaces) defines hierarchy:
token-itemize/
├── token_itemize/
│ ├── __init__.py
│ ├── cli.py
│ └── main.py
└── tests/
└── test_main.py
Running this with Treefile will create the full directory structure.
Command Line Arguments
Treefile supports the following command line arguments:
treefile [OPTIONS] --file <PATH>
Available options:
--file <PATH>: Path to the.treefilefile (required)--output <PATH>: Output directory (default: current directory)--venv <NAME>: Name for virtual environment (default: .venv)--py <VERSION>: Python version for virtual environment--activate: Activate the virtual environment after creation--dry-run: Preview changes without creating files/directories--force: Overwrite existing files/directories if conflicts occur--version: Show package version
Features
1. File Tree Generation
Treefile parses a .treefile file and creates the corresponding directory structure with files and directories.
2. Virtual Environment Management
Treefile can create virtual environments based on specified Python versions. If you include a venv section in your configuration, it will automatically handle environment creation.
3. Context Menu Integration
Treefile supports right-click context menu integration (Unpack Treefile) for .treefile files on Windows, macOS, and Linux:
- Windows: Register the context menu and file icon using
register_icon.bat - macOS/Linux: Use
register_icon.shto set up custom file icons and context menu actions.
4. File Icon Integration
Treefile integrates with Windows Explorer and the POSIX file manager of your choice to display custom icons for .treefile files:
- Windows: Register the context menu and file icon using
register_icon.bat - macOS/Linux: Use
register_icon.shto set up custom file icons and the context menu actions.
5. Embedded Configuration
You can embed configuration options directly in your .treefile file by adding a comment line starting with #!treefile::
#!treefile: --venv .venv --py python3.8
token-itemize/
├── token_itemize/
│ ├── __init__.py
│ ├── cli.py
│ └── main.py
└── tests/
└── test_main.py
Configuration File
Treefile uses a config.yaml file for default settings:
venv: ".venv"
python: "python"
output: "."
This allows you to set defaults for virtual environments, Python versions, and output directories.
Context Menu and File Icon Integration
Optionally run the following command to register the context menu and file icon if you want to have it integrated with your operating system:
Windows
Run the .bat file as administrator:
scripts/register_icon.bat
macOS/Linux
Make the script executable and run it:
chmod +x scripts/register_icon.sh && ./scripts/register_icon.sh
Contributing
Contributions are welcome! Please fork this repository and submit a pull request.
License
Treefile is distributed under the MIT License. See LICENSE for details.
Metadata
Release files for treefile 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treefile-1.0.0.tar.gz | 1.5 MB | Without provenance | Details for treefile-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| treefile-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for treefile-1.0.0-py3-none-any.whl |
Total release size: 3.0 MB
Release files / treefile-1.0.0.tar.gz
| Download URL | treefile-1.0.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b9110242df621c857325059d1e5eff316351122f4ff05b71058add09edaee19
|
|
BLAKE2b-256 checksum How to use checksums |
368b637a38c3c67412dbd97f03b611607765196336bab8d97bed04a1167b92ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / treefile-1.0.0-py3-none-any.whl
| Download URL | treefile-1.0.0-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7ddaec35802aac28677a9ceba92aa17a457877f56bb2bd1d654cdc90710e388
|
|
BLAKE2b-256 checksum How to use checksums |
6cfc0c2365df68361e01e3b92dedc147cb98a4ec0cd454df297d2e790e7cf885
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Security for treefile 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.