19 lines
1.1 KiB
Python
19 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
import os, sys, re
|
|
folder = os.path.abspath(sys.argv[1]) if len(sys.argv) > 1 else os.getcwd()
|
|
files = [f for f in os.listdir(folder) if f.endswith('.html') and f != '总览.html']
|
|
for name in sorted(files):
|
|
p = os.path.join(folder, name)
|
|
with open(p, encoding='utf-8') as f:
|
|
c = f.read()
|
|
star_html = (len(c.split('<div class="metrics">')) - 1) + c.count('class="star ') + c.count('class="star-rating')
|
|
star_css = len(re.findall(r'\.star-rating \{|\.metric-item \{|\.metric-label \{|\.star \{|\.star\.filled|\.half-filled\.', c))
|
|
star_js = len(re.findall(r'function initStarRatings|function setStarRating|initStarRatings\(\);', c))
|
|
bf = c.count('backdrop-filter')
|
|
car = 'id="cardsSlider"' in c
|
|
sc_dn = '.student-card { display: none; }' in c
|
|
opens = c.count('<div'); closes = c.count('</div>')
|
|
bal = 'OK' if opens == closes else 'MISMATCH %d/%d' % (opens, closes)
|
|
print('%-46s carousel=%-5s starHTML=%d starCSS=%d starJS=%d backdrop=%d scdn=%s div=%s' % (
|
|
name, car, star_html, star_css, star_js, bf, sc_dn if car else 'n/a(scroll)', bal))
|