upload de projetos funcional + busca por bpm
This commit is contained in:
1 parent
051dfddd60
commit
538929175a
5 files changed
+116
-14
No files matched your search
@@ -3,18 +3,18 @@
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import yaml # <--- Requer: pip install pyyaml
|
||||
|
||||
# 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.
|
||||
Suporta JSON e YAML automaticamente baseado na extensão.
|
||||
"""
|
||||
logging.info("=== Iniciando Geração de Manifestos (Pós-Processamento) ===")
|
||||
logging.info("=== Iniciando Geração de Manifestos (YAML/JSON) ===")
|
||||
|
||||
# Estrutura para o relatório
|
||||
report = {"generated": [], "failed": []}
|
||||
|
||||
for config in CONFIGS:
|
||||
@@ -39,8 +39,13 @@ def generate_manifests(project_root_path):
|
||||
output_dir = os.path.dirname(output_file_abs)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
# DECISÃO: Salvar como YAML ou JSON baseado na extensão
|
||||
with open(output_file_abs, "w", encoding="utf-8") as f:
|
||||
json.dump(result_data, f, indent=2, ensure_ascii=False)
|
||||
if output_file_abs.endswith(".yml") or output_file_abs.endswith(".yaml"):
|
||||
# allow_unicode=True é CRUCIAL para acentos funcionarem
|
||||
yaml.dump(result_data, f, allow_unicode=True, default_flow_style=False)
|
||||
else:
|
||||
json.dump(result_data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
logging.info(f"Manifesto salvo: {output_file_abs}")
|
||||
report["generated"].append(config["output_file"])
|
||||
@@ -49,4 +54,4 @@ def generate_manifests(project_root_path):
|
||||
logging.error(f"Erro ao gerar {config['output_file']}: {e}")
|
||||
report["failed"].append(f"{config['output_file']} (Erro: {str(e)})")
|
||||
|
||||
return report
|
||||
return report
|
||||
@@ -34,7 +34,7 @@ CONFIGS = [
|
||||
},
|
||||
{
|
||||
"source_dir": WAV_FOLDER, # Vai ler a pasta src_mmpSearch/wav
|
||||
"output_file": os.path.join(DATA_FOLDER, "beats.json"), # Salva em _data/beats.json
|
||||
"output_file": os.path.join(DATA_FOLDER, "beats.yml"), # Salva em _data/beats.json
|
||||
"scan_type": "list",
|
||||
"extensions": [".wav", ".mp3"], # Extensões permitidas
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user