#!/usr/bin/env python3 """Обновление манифеста ресурсов при разработке; изменения проверяются перед выпуском.""" import hashlib,json from pathlib import Path root=Path(__file__).resolve().parents[1] files=[] for folder in ('data','schemas'): for p in sorted((root/folder).rglob('*.json')):files.append((p.relative_to(root).as_posix(),p)) for p in sorted((root/'resources/tasks').rglob('*')): if p.is_file():files.append((p.relative_to(root/'resources').as_posix(),p)) files.extend([('styles/dedsec.qss',root/'resources/styles/dedsec.qss'),('fixtures/demo.inventory.json',root/'tests/fixtures/demo.inventory.json')]) manifest={'schema_version':1,'assets':[{'path':alias,'sha256':hashlib.sha256(path.read_bytes()).hexdigest()} for alias,path in files]} (root/'resources/asset-manifest.json').write_text(json.dumps(manifest,indent=2)+'\n') files.append(('asset-manifest.json',root/'resources/asset-manifest.json')) import os (root/'resources/resources.qrc').write_text('\n'+''.join(f' {os.path.relpath(path,root/"resources")}\n' for alias,path in files)+'\n') print(f'Обновлены хеши встроенных ресурсов ({len(manifest["assets"])}) и resources.qrc')