Created
December 5, 2024 09:57
-
-
Save garybake/f4831d2679634fb5b926f8e2a8689561 to your computer and use it in GitHub Desktop.
Print project structure, for pasting into chatgpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
When asking for help with chatgpt it's sometimes helpful to add | |
in your project structure for context. | |
""" | |
import os | |
ignore = ['venv', '.git', '.pytest_cache', '__pycache__'] | |
def print_structure(root_dir, indent=""): | |
for item in os.listdir(root_dir): | |
if not item.endswith('.pyc') and item not in ignore: | |
item_path = os.path.join(root_dir, item) | |
print(f"{indent}{item}/" if os.path.isdir(item_path) else f"{indent}{item}") | |
if os.path.isdir(item_path): | |
if item not in ignore: | |
print_structure(item_path, indent + " ") | |
print_structure(".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment