This repository has been archived on 2025-11-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Fitz_Studio/scripts/datos_para_llms/generar_tree.py
T
egutierrez c47b9474f4 feat: Implement text manager API and database connection
- Added `text_manager.py` to handle the creation of text libraries via FastAPI.
- Introduced database connection management in `conexion.py` using PostgreSQL credentials from environment variables.
- Created abstract base class `EmbedderABC` in `Base_Embedder.py` for embedding models.
- Developed `OpenAIEmbedder` class to generate embeddings using OpenAI's API.
- Implemented `OpenAIEmbedderModel` and repository pattern for managing OpenAI embedders in `Openai_embedder_mmr.py`.
- Established `Biblioteca` class for managing text libraries and their associated notes in `biblioteca.py`.
- Created SQLAlchemy models and mappers for `Biblioteca` and `Nota` in `biblioteca_mmr.py` and `notas_biblioteca_mmr.py`.
- Added functionality for dynamic table generation for notes associated with libraries.
- Included comprehensive methods for adding, retrieving, and managing notes and libraries in their respective repositories.
2025-05-10 17:52:43 +02:00

32 lines
1.1 KiB
Python

import os
def generate_tree(start_path='.', max_depth=2):
lines = []
def _tree(dir_path, depth, prefix):
if depth > max_depth:
return
entries = sorted(os.listdir(dir_path))
for i, entry in enumerate(entries):
path = os.path.join(dir_path, entry)
connector = "└── " if i == len(entries) - 1 else "├── "
lines.append(prefix + connector + entry)
if os.path.isdir(path):
extension = " " if i == len(entries) - 1 else ""
_tree(path, depth + 1, prefix + extension)
lines.append(start_path)
_tree(start_path, 1, '')
return '\n'.join(lines)
def save_tree_to_file(start_path='.', max_depth=2, output_file='tree.txt'):
tree_output = generate_tree(start_path, max_depth)
with open(output_file, 'w', encoding='utf-8') as f:
f.write(tree_output)
print(f"Árbol guardado en: {output_file}")
# Ejemplo de uso:
# Puedes cambiar estos valores según lo necesites
save_tree_to_file(start_path=r'E:\Fitz_Studio', max_depth=3, output_file=r'E:\Fitz_Studio\data\files\txt\tree.txt')