Skip to main content

Takes a folder path and outputs a text representation of the folders and files, supports ignore files.

Project description

Folder Tree Generator

PyPI version

Test

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

folder_tree_generator-0.1.9.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

folder_tree_generator-0.1.9-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page