Files
xk-doctor-wx/_tmp_scan_excipient.py

50 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
import re
from pathlib import Path
files = [
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_workbench\prescription_v2\components\modals\ChineseMedicineModal.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_workbench\prescription_v2\index.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_clinic_admin\order\components\PrescriptionDetailPopup.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_business_shared\order\components\PrescriptionDetailPopup.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_my\prescriptionDetail.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_workbench\prescriptionDetail.vue'),
Path(r'd:\worker\code\xk-doctor-wx\subPackages\sub_workbench\prescription_v2\components\modals\SimpleProductModal.vue'),
]
for p in files:
if not p.exists():
print('MISSING', p)
continue
text = p.read_text(encoding='utf-8')
lines = text.splitlines()
in_tpl = False
issues = []
for i, line in enumerate(lines, 1):
if re.match(r'\s*<template[\s>]', line) or line.strip() == '<template>':
in_tpl = True
continue
if re.match(r'\s*</template>', line):
in_tpl = False
continue
if not in_tpl:
continue
stripped = line.strip()
if '??' in line or re.search(r'\?\.[A-Za-z_\[]', line):
issues.append((i, 'optional', stripped[:140]))
if re.search(r':class\s*=\s*"[^"]*[a-zA-Z_][\w]*\([^)]*\)', line) or re.search(r":class\s*=\s*'[^']*[a-zA-Z_][\w]*\([^)]*\)", line):
issues.append((i, 'class-fn', stripped[:140]))
if re.search(r':style\s*=\s*"[^"]*[a-zA-Z_][\w]*\([^)]*\)', line) or re.search(r":style\s*=\s*'[^']*[a-zA-Z_][\w]*\([^)]*\)", line):
issues.append((i, 'style-fn', stripped[:140]))
if 'page-container' in line and 'v-show' in line:
issues.append((i, 'pc-vshow', stripped[:140]))
if re.search(r'v-if\s*=\s*"[^"]*\bshow\b[^"]*"', line) and 'page-container' in ''.join(lines[max(0,i-3):i+2]):
# crude: same-var check later
pass
print('===', p.name, '===')
if not issues:
print(' (no template ??/?. / class-fn / style-fn)')
else:
for it in issues:
print(' L%s [%s] %s' % (it[0], it[1], it[2]))