[WORK] UI: вкладки «План комнаты» и «Покрытие», кнопка «Спецификация»; проверка целостности UI (check_webui.py)
This commit is contained in:
1 parent
84bbf33147
commit
461cbe8e2d
2 files changed
+106
-1
No files matched your search
@@ -0,0 +1,46 @@
|
||||
#!/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())
|
||||
Reference in new issue
Block a user