Files
kefu/deploy/patient-session-20260918/finalize_sources.py
T
2026-09-21 10:34:06 +08:00

24 lines
1.6 KiB
Python

from pathlib import Path
import difflib,shutil,json
src=Path(r'C:\kefu\wechat_rpa');prod=Path(r'C:\wechat_rpa');task=Path(r'C:\kefu\deploy\patient-session-20260918')
for name in ['zyt_patient_client.py','archive_api.py','archive_store.py']:
before=(task/'before-backend'/name).read_text(encoding='utf-8-sig')
current=(prod/name).read_text(encoding='utf-8-sig')
assert current==before, name+' production differs from source baseline'
shutil.copyfile(src/name,prod/name)
name='admin_api.py';before=(task/'before-backend'/name).read_text(encoding='utf-8-sig').splitlines(keepends=True)
after=(src/name).read_text(encoding='utf-8-sig').splitlines(keepends=True)
current=(prod/name).read_text(encoding='utf-8-sig')
for group in difflib.SequenceMatcher(None,before,after,autojunk=False).get_grouped_opcodes(3):
old=''.join(before[group[0][1]:group[-1][2]])
new=''.join(after[group[0][3]:group[-1][4]])
assert current.count(old)==1,repr(old[:150])
current=current.replace(old,new,1)
compile(current,str(prod/name),'exec');(prod/name).write_text(current,encoding='utf-8',newline='\n')
for name in ['test_zyt_session_recovery.py']:
shutil.copyfile(src/name,prod/name)
plan=json.loads((task/'patient-release-plan.template.json').read_text(encoding='utf-8-sig'))
plan['finalized']=True
plan['windowsTestModules']=['test_patient_session_client','test_patient_session_dialog','test_zyt_patient_client','test_zyt_auth','test_desktop_login']
(task/'patient-release-plan.json').write_text(json.dumps(plan,ensure_ascii=False,indent=2),encoding='utf-8')
print('4 backend files synchronized without overwriting protocol-only routes; plan finalized')