A tool to generate structured representations of directories
Project description
dirstructx – Directory Structure Generator 📂
dirstructx is a Python package that generates structured representations of a directory. It supports multiple output formats such as JSON, YAML, and tree-like structures, making it useful for documenting project structures or analyzing filesystem layouts.
✨ Features
- Generate directory structures recursively with flexible formatting
- Supports multiple output formats:
json(machine-readable)yaml(configuration-friendly)tree(human-readable)
- CLI Usage for quick execution in the terminal
- Library Usage for integration into Python projects
- Custom Sorting Options:
- List files before directories or directories first
- Sort alphabetically or keep the natural order
🛠 Installation
To install dirstructx, clone the repository and install dependencies:
git clone https://github.com/muldercw/dirstructx.git
cd dirstructx
pip install -r requirements.txt
Or install via pip (if published on PyPI):
pip install dirstructx
🚀 Usage
You can use dirstructx via CLI or as a Python library.
📌 CLI Usage
Run dirstructx on any directory:
python -m dirstructx /path/to/project --format tree
Available output formats:
python -m dirstructx /path/to/project --format json
python -m dirstructx /path/to/project --format yaml
python -m dirstructx /path/to/project --format tree
To redirect output to a file:
python -m dirstructx /path/to/project --format tree > output.txt
📜 Example Output
JSON Output (--format json)
{
"README.md": null,
"setup.py": null,
"src": {
"__init__.py": null,
"main.py": null,
"utils": {
"helpers.py": null,
"formatters.py": null
}
}
}
YAML Output (--format yaml)
README.md: null
setup.py: null
src:
__init__.py: null
main.py: null
utils:
helpers.py: null
formatters.py: null
Tree Output (--format tree)
├── README.md
├── setup.py
└── src
├── __init__.py
├── main.py
└── utils
├── helpers.py
└── formatters.py
🖥️ Library Usage
You can also use dirstructx in your Python scripts:
from dirstructx import generate_structure
directory_path = "/path/to/project"
structure = generate_structure(directory_path)
print(structure) # Prints the directory structure as a dictionary
To format the output in JSON:
import json
print(json.dumps(structure, indent=4))
Or in YAML:
import yaml
print(yaml.dump(structure, default_flow_style=False))
📝 License
This project is licensed under the MIT License.
📫 Contact
For any issues or feature requests, please open an issue on GitHub.
Happy coding! 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dirstructx-0.1.0.tar.gz.
File metadata
- Download URL: dirstructx-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04864acbe84734f667e0cd20fb50ceb5e8c4e6af3d4584dc5a4a4459576d4d9b
|
|
| MD5 |
7257891c353c65b5b2d9a0e0f6a353cf
|
|
| BLAKE2b-256 |
6a3a47f51e0c3ab62b4ad766e7e94ba586d8189079c6360971847e39f1be61fe
|
File details
Details for the file dirstructx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dirstructx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42c673b3496dd6976b1224e0b70e78fa67ff61379528eccfe727c3c4cd137789
|
|
| MD5 |
84c2a8cd13084fc64e31df544e5e2ff3
|
|
| BLAKE2b-256 |
2725292b54e39596eecf8ec628d049f1225bbaf46f5b7765020cdb72f374f1b9
|