melhorando desempenho dos scripts de indexação e inserindo mais projetos
This commit is contained in:
1 parent
c8323d56cf
commit
42da68afa0
463 files changed
+1015734
-73118
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# manifest_generator.py
|
||||
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
|
||||
# Caminhos relativos baseados na raiz do projeto passada como argumento
|
||||
from utils import CONFIGS, scan_directory_list, scan_directory_tree
|
||||
|
||||
|
||||
def generate_manifests(project_root_path):
|
||||
"""
|
||||
Gera os manifestos e retorna um dicionário com estatísticas.
|
||||
"""
|
||||
logging.info("=== Iniciando Geração de Manifestos (Pós-Processamento) ===")
|
||||
|
||||
# Estrutura para o relatório
|
||||
report = {"generated": [], "failed": []}
|
||||
|
||||
for config in CONFIGS:
|
||||
source_dir_abs = os.path.join(project_root_path, config["source_dir"])
|
||||
output_file_abs = os.path.join(project_root_path, config["output_file"])
|
||||
scan_type = config["scan_type"]
|
||||
|
||||
if not os.path.isdir(source_dir_abs):
|
||||
logging.warning(f"Diretório fonte não encontrado: {source_dir_abs}")
|
||||
report["failed"].append(f"{config['output_file']} (Fonte ausente)")
|
||||
continue
|
||||
|
||||
result_data = None
|
||||
try:
|
||||
if scan_type == "tree":
|
||||
result_data = scan_directory_tree(source_dir_abs)
|
||||
elif scan_type == "list":
|
||||
extensions = config.get("extensions", [])
|
||||
result_data = scan_directory_list(source_dir_abs, extensions)
|
||||
|
||||
if result_data is not None:
|
||||
output_dir = os.path.dirname(output_file_abs)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
with open(output_file_abs, "w", encoding="utf-8") as f:
|
||||
json.dump(result_data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
logging.info(f"Manifesto salvo: {output_file_abs}")
|
||||
report["generated"].append(config["output_file"])
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Erro ao gerar {config['output_file']}: {e}")
|
||||
report["failed"].append(f"{config['output_file']} (Erro: {str(e)})")
|
||||
|
||||
return report
|
||||
Reference in new issue
Block a user