Files
kefu/deploy/protocol-integration-20260916/fix_qt_merge.py
T
2026-09-21 10:34:06 +08:00

27 lines
1.2 KiB
Python

from pathlib import Path
import ast
folder = Path(__file__).resolve().parent
for root in [Path('C:/wechat_rpa'), folder / 'payload']:
path = root / 'wechat_gui_qt.py'
text = path.read_text(encoding='utf-8')
old = ''' manage_knowledge.clicked.connect(open_knowledge_center)
lambda: QDesktopServices.openUrl(QUrl.fromLocalFile(str(SCRIPT_DIR)))
)'''
assert text.count(old) == 1
text = text.replace(old, ' manage_knowledge.clicked.connect(open_knowledge_center)')
ast.parse(text)
path.write_text(text, encoding='utf-8', newline='\n')
path = folder / 'stage.py'
text = path.read_text(encoding='utf-8')
old = " old=next(line.strip() for line in dst.splitlines() if 'manage_knowledge.clicked.connect' in line)"
new = ''' old = """manage_knowledge.clicked.connect(
lambda: QDesktopServices.openUrl(QUrl.fromLocalFile(str(SCRIPT_DIR)))
)"""'''
assert text.count(old) == 1
path.write_text(text.replace(old, new), encoding='utf-8', newline='\n')
for path in (folder / 'payload').glob('*.py'):
ast.parse(path.read_text(encoding='utf-8-sig'))
print('Qt merge fixed; all staged Python syntax checks passed')