26 lines
2.2 KiB
Python
26 lines
2.2 KiB
Python
from pathlib import Path
|
|
import csv, json, hashlib, datetime
|
|
root=Path(__file__).resolve().parents[2]; out=Path(__file__).resolve().parent
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
deployed=root/'outputs/investmoz-negocios-classificacao-ativacao-20261016'
|
|
manifest=json.loads((deployed/'MANIFESTO-CURRENT.json').read_text('utf-8'))
|
|
build=json.loads((deployed/'COMPILACAO-NOME-QA.json').read_text('utf-8'))
|
|
paths=set(x['path'] for x in manifest['sources'])|set(x['path'] for x in build['build'])
|
|
for folder in ['app','database','resources','routes','config','bootstrap']:
|
|
paths.update(p.relative_to(root).as_posix() for p in (root/folder).rglob('*') if p.is_file() and 'cache/' not in p.relative_to(root/folder).as_posix())
|
|
paths.update(n for n in ['.env','composer.json','composer.lock','package.json','package-lock.json','vite.config.ts','AGENTS.md'] if (root/n).is_file())
|
|
baseline={'date':'2026-10-16','scope':'Active files read only; no active database connection','files':[{'path':p,'sha256':sha(root/p),'bytes':(root/p).stat().st_size} for p in sorted(paths)],'candidate_sources':11,'candidate_build':161}
|
|
assert all(sha(root/x['path'])==x['after_sha256'] for x in manifest['sources'])
|
|
assert all(sha(root/x['path'])==x['sha256'] for x in build['build'])
|
|
assert not (out/'BASELINE-FICHEIROS.json').exists()
|
|
(out/'BASELINE-FICHEIROS.json').write_text(json.dumps(baseline,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
csv.field_size_limit(10000000)
|
|
with (root/'docs/investmoz/v2/auditoria-portal/matriz-requisitos.csv').open(encoding='utf-8-sig',newline='') as f: rows=list(csv.DictReader(f))
|
|
matches=[]
|
|
for r in rows:
|
|
text=(r['Pedido/trecho']+' '+r['Critério de aceitação']).casefold()
|
|
if any(s in text for s in ['cadeia de valor','cadeias de valor','subsector','subsector','atividade económica','actividade económica','referências económicas']):
|
|
matches.append({k:r[k] for k in ['ID','Pedido/trecho','Critério de aceitação','Estado','Lacuna','Dependência']})
|
|
(out/'REQUISITOS-EXISTENTES.json').write_text(json.dumps(matches,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
print(json.dumps({'protected_files':len(paths),'matrix_rows':len(rows),'matching_requirements':len(matches)}))
|