# -*- coding: utf-8 -*- """枚举 demo index.html 的 api(...) 调用首参(含模板串/拼接),评估旧契约影响面。""" import io import re import sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8") f = r"e:\code\crm-backend-matt\.scratch\customer-e2e\demo\index.html" src = open(f, encoding="utf-8").read() # api('xxx' / api(`/...` / api(URL 变量或拼接表达式 —— 抓前 120 字符 calls = [] for m in re.finditer(r"\bapi\(\s*([^,)]{1,140})", src): calls.append(" ".join(m.group(1).split())) for i, c in enumerate(calls, 1): print(f"{i:3d}. {c}") print(f"total {len(calls)} calls")