47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Проверка нового UI: обработчики, id, вкладки, используемые API."""
|
|
import re
|
|
import sys
|
|
|
|
P = "/root/buryan-infra/ops/work/web/webui.html"
|
|
|
|
|
|
def main():
|
|
s = open(P, encoding="utf-8").read()
|
|
defs = set(re.findall(r"function\s+(\w+)", s))
|
|
handlers = set(re.findall(r'on(?:click|change|input|keydown)="(\w+)\(', s))
|
|
ids = set(re.findall(r'id="([\w-]+)"', s))
|
|
used = set(re.findall(r"\$\('#([\w-]+)'\)", s))
|
|
tabs = set(re.findall(r'data-t="(\w+)"', s))
|
|
sections = set(re.findall(r'id="sec-(\w+)"', s))
|
|
apis = sorted(set(re.findall(r"SVC\.(\w+)", s)))
|
|
|
|
problems = []
|
|
for h in sorted(handlers):
|
|
if h not in defs:
|
|
problems.append("обработчик без функции: " + h)
|
|
for u in sorted(used):
|
|
if u not in ids:
|
|
problems.append("id не найден: " + u)
|
|
for t in sorted(tabs):
|
|
if t not in sections:
|
|
problems.append("вкладка без секции: " + t)
|
|
for sec in sorted(sections):
|
|
if sec not in tabs:
|
|
problems.append("секция без вкладки: " + sec)
|
|
|
|
print("функций:", len(defs), "| обработчиков:", len(handlers))
|
|
print("вкладок:", len(tabs), "| секций:", len(sections))
|
|
print("сервисы:", ", ".join(apis))
|
|
if problems:
|
|
print("ПРОБЛЕМЫ (%d):" % len(problems))
|
|
for p in problems:
|
|
print(" -", p)
|
|
return 1
|
|
print("ИТОГ: OK")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|