Files
sanguo_vnpy_v2/scripts/qmt_relogin/qmt_xmldump2.py
T

41 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
"""Read-only round 2: locate the INSTANCE element (startupAutorun) precisely."""
import os
import re
d = open(r"C:\sanguo_bigqmt\qmt_install_dir.txt", encoding="utf-8").read().strip()
root = os.path.dirname(d)
def esc(s):
return s.encode("unicode_escape").decode("ascii")
p1 = os.path.join(root, "config", "indexUserConfig.xml")
t1 = open(p1, encoding="utf-8", errors="replace").read()
print("### startupAutorun occurrences:", t1.count("startupAutorun"))
for m in re.finditer("startupAutorun", t1):
a = max(0, m.start() - 900)
b = min(len(t1), m.end() + 400)
print("=== SA ctx ===")
print(esc(t1[a:b]))
print("=== end ===")
print("### name occurrences:", t1.count("新建策略文件3"))
for i, m in enumerate(re.finditer("新建策略文件3", t1)):
a = max(0, m.start() - 200)
b = min(len(t1), m.end() + 200)
print("--- occ%d pos%d ---" % (i, m.start()))
print(esc(t1[a:b]))
# Config.xml modbootstart compact
p2 = os.path.join(root, "userdata", "users", "66639661", "Config.xml")
t2 = open(p2, encoding="utf-8", errors="replace").read()
print("### modbootstart occurrences:", t2.lower().count("modbootstart"))
for m in re.finditer("modbootstart", t2, re.I):
a = max(0, m.start() - 150)
b = min(len(t2), m.end() + 150)
print(esc(t2[a:b]))
print("DONE2")