Spaces:
Sleeping
Sleeping
Download scripts/sync_mesa_redutores.py from gui-sparim/teste_docs: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/gui-sparim/teste_docs/resolve/main/scripts/sync_mesa_redutores.py
- Command line
-
hf download hf://spaces/gui-sparim/teste_docs/scripts/sync_mesa_redutores.py
-
curl -L -o sync_mesa_redutores.py https://huggingface.co/spaces/gui-sparim/teste_docs/resolve/main/scripts/sync_mesa_redutores.py
1.29 kB
| """Sincroniza o catálogo versionado da MESA sem importar seu backend.""" | |
| import ast | |
| import json | |
| from pathlib import Path | |
| import sys | |
| root = Path(__file__).resolve().parents[1] | |
| mesa = Path(sys.argv[1]) if len(sys.argv) > 1 else root.parent / "mesa-frame" | |
| source = mesa / "backend/app/core/redutores_territoriais.py" | |
| tree = ast.parse(source.read_text(encoding="utf-8")) | |
| version = next(ast.literal_eval(node.value) for node in tree.body | |
| if isinstance(node, ast.Assign) | |
| and any(isinstance(target, ast.Name) and target.id == "VERSAO_REGRAS_REDUTORES" for target in node.targets)) | |
| catalog = next(node.value for node in tree.body if isinstance(node, ast.AnnAssign) | |
| and isinstance(node.target, ast.Name) and node.target.id == "CATALOGO_REDUTORES") | |
| class ResolveVersion(ast.NodeTransformer): | |
| def visit_Name(self, node): | |
| return ast.Constant(value=version) if node.id == "VERSAO_REGRAS_REDUTORES" else node | |
| data = {"origem": "mesa-frame/backend/app/core/redutores_territoriais.py", | |
| "catalogo": ast.literal_eval(ResolveVersion().visit(catalog))} | |
| destination = root / "config/mesa_redutores.json" | |
| destination.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| print(f"Catálogo sincronizado: {version}") | |