13 lines
581 B
Python
13 lines
581 B
Python
from pathlib import Path
|
|
|
|
base = Path(__file__).parent
|
|
replacement = (base / 'browser_index_sql.txt').read_text(encoding='utf-8')
|
|
for root in (Path('C:/wechat_rpa'), Path('C:/kefu/wechat_rpa')):
|
|
path = root / 'wxwork_message_browser.py'
|
|
raw = path.read_bytes()
|
|
source = raw.decode('utf-8').replace('\r\n', '\n')
|
|
start = source.index('def _message_index(')
|
|
end = source.index('def _read_message_rows(', start)
|
|
source = source[:start] + replacement + source[end:]
|
|
path.write_bytes(source.replace('\n', '\r\n' if b'\r\n' in raw else '\n').encode('utf-8'))
|