"""Refresh the reviewed standalone section; runtime never imports from SMB.""" import json from pathlib import Path ROOT=Path(__file__).resolve().parent RUNNER=ROOT.parent/'deploy-runner/nodedc-deploy' START='# BEGIN GENERATED CMS DEPLOYMENT\n' END='# END GENERATED CMS DEPLOYMENT\n' def section(): release=(ROOT/'release_runtime.py').read_text().replace('__CMS_BASELINE__',repr(json.loads((ROOT/'baseline.json').read_text()))).replace('__CMS_FOUNDATION__',repr(json.loads((ROOT/'foundation.json').read_text()))) ci=(ROOT/'ci_runtime.py').read_text().replace('__CMS_CI_HASHES__',repr(json.loads((ROOT/'ci-source-sha256.json').read_text()))) auto=(ROOT/'autodeploy_runtime.py').read_text() library='def cms_autodeploy_library():\n' for file in ('deployment_queue.py','gitea_source.py','controller.py'): lines=[line for line in (ROOT/file).read_text().splitlines() if not line.startswith('from deployment_queue import ')] library+='\n'.join(' '+line if line else '' for line in lines)+'\n\n' library+=' return DeploymentQueue, GiteaSource, Controller, (QueueError, SourceError)\n' audit=(ROOT/'audit_runtime.py').read_text() return START+release+'\n'+ci+'\n'+auto+'\n'+audit+'\n'+library+END if __name__=='__main__': before,rest=RUNNER.read_text().split(START,1);_,after=rest.split(END,1) RUNNER.write_text(before+section()+after)