Takes a folder path and outputs a text representation of the folders and files, supports ignore files.
Project description
Folder Tree Generator
Folder Tree Generator is a Python module that takes a folder path and outputs a text representation of the folders and files. It supports ignore files, such as .gitignore
, to exclude certain files or folders from the output.
typical string output:
my_project/
|-- .gitignore
|-- main.py
|-- utils.py
|-- data/
| |-- input.txt
| |-- output.txt
Why?
I needed a way to generate folder structures in a standard text format that I could copy and paste into GPT without including all the build artifacts, eg. repository structures for code analysis. If you wanted to make your own ignore file it should be a simple adapation of a gitignore file, in 90% of my use cases, the gitignore is sufficient.
Installation
You can install the module from PyPI using pip:
pip install folder-tree-generator
Usage
You can use the module as a command-line tool or import it in your Python script.
Command-line usage
python -m folder_tree_generator/folder_tree_generator /path/to/your/folder
Python script usage
from folder_tree_generator import generate_tree
output_text = generate_tree("/path/to/your/folder")
print(output_text)
Configuration
By default, the module looks for a .gitignore
file in the root folder to determine which files and folders to ignore. You can change the ignore file name by passing an optional argument to the generate_tree
function:
output_text = generate_tree("/path/to/your/folder", ignore_file_name=".myignore")
Development
To set up the development environment, clone the repository and install the required dependencies using Poetry:
git clone https://github.com/seandearnaley/folder-tree-generator.git
cd folder-tree-generator
poetry install
To run the tests, use the following command:
poetry run pytest
Make sure to update the README.md file with these changes.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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
Hashes for folder_tree_generator-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43f33f65ba6255d946f0901f3cad8c8521c7f25053f27a5acf95cfc07bc18ce2 |
|
MD5 | 1ec48509ffbcdfcd5a9d7b74df03b35e |
|
BLAKE2b-256 | 6cfebbc18edb4187500d38a41b5bbd275a36f684740caa02fa0947b731655f19 |
Hashes for folder_tree_generator-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19eba945bc85e6caa6d39535ddd81327c3e4da55cb8d97427e8ca74a946751f |
|
MD5 | 8fb04547bb1f72f3fd33d2ed2349a306 |
|
BLAKE2b-256 | 82b77c99d4d4ddd32d0720b5e8ea3192b7784fab260c2106bcc3f85da725501e |