from pathlib import Path import shutil p = Path(r'C:\wechat_rpa\protocol_engine.py') s = p.read_text(encoding='utf-8') s = s.replace(" def _register_assistant_review(self,key,state,context=None):\n", " def _register_assistant_review(self,key,state,context=None):\n if not self._assistant_call('enabled'):return\n", 1) s = s.replace(" def _reconcile_assistant_review(self,key,state,context=None):\n", " def _reconcile_assistant_review(self,key,state,context=None):\n if not self._assistant_call('enabled'):return False\n", 1) p.write_text(s,encoding='utf-8',newline='') shutil.copy2(Path(__file__).with_name('test_protocol_review_assistant.py'), p.with_name('test_protocol_review_assistant.py'))