18 lines
672 B
Python
18 lines
672 B
Python
#!/usr/bin/env python3
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
from sys import exit
|
|
root=Path(__file__).resolve().parent.parent
|
|
state=root/'state'/'sync.json'
|
|
if not state.exists():raise SystemExit('Kein Sync-Status vorhanden')
|
|
s=json.loads(state.read_text())
|
|
assert s.get('documents')==len(s.get('index',[]))
|
|
files=list((root/'data'/'csaf').glob('*/*.json'))
|
|
if len(files)!=s['documents']:
|
|
raise SystemExit(f'Unvollständig: {len(files)} Dateien, {s["documents"]} erwartet')
|
|
for p in files:
|
|
obj=json.loads(p.read_bytes())
|
|
if not isinstance(obj.get('document'),dict):raise SystemExit(f'CSAF ungültig: {p}')
|
|
print(f'VALID: {len(files)} CSAF-Dokumente')
|