/
shaman_mir
/
generate_code_tree
Обзор
Документация
Войти
/
shaman_mir
/
generate_code_tree
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
generate_code_tree.py
31 строка
1 KB
Руслан Миронов
upload files
12 янв 2026, 07:26
12 янв 2026, 07:26
8a2d118
Код
Авторство
О чём код?
import os def get_file_content(file_path): with open(file_path, 'r', encoding='utf-8') as file: return file.read() def generate_code_tree(root_dir, output_file): with open(output_file, 'w', encoding='utf-8') as f: for root, dirs, files in os.walk(root_dir): # Печатаем структуру папок level = root.replace(root_dir, '').count(os.sep) indent = ' ' * 4 * level f.write(f"{indent}{os.path.basename(root)}\n") # Печатаем файлы for file in files: file_path = os.path.join(root, file) if file.endswith('.py'): #and file != 'johabfreq.py' langbulgarianmodel.py and file != 'idnadata.py' and file != 'uts46data.py' f.write(f"{indent} {file}\n") f.write(f"{indent} /////\n") f.write(f"{indent} {get_file_content(file_path)}\n") f.write(f"{indent} /////\n") else: f.write(f"{indent} {file}\n") if __name__ == "__main__": root_dir = os.getcwd() # Текущая рабочая директория output_file = "Code_Tree.txt" generate_code_tree(root_dir, output_file) print(f"Файл {output_file} успешно создан.")