26 lines
942 B
Python
26 lines
942 B
Python
"""Rules that differ between the bootstrap CSS of two builds: python css_rule_diff.py LIVE_DIST OTHER_DIST"""
|
|
import re, sys
|
|
from pathlib import Path
|
|
|
|
REF = re.compile(r'[A-Za-z0-9_.-]+?-[A-Za-z0-9_-]{8}\.(?:js|css)')
|
|
|
|
|
|
def boot(root):
|
|
root = Path(root)
|
|
names = {p.name: p for p in root.rglob('*') if p.is_file()}
|
|
seen, todo = set(), ['index.html']
|
|
while todo:
|
|
n = todo.pop()
|
|
if n in seen:
|
|
continue
|
|
seen.add(n)
|
|
p = root / n if n == 'index.html' else names[n]
|
|
todo += [m for m in REF.findall(p.read_text(encoding='utf-8', errors='replace')) if m in names]
|
|
return next(names[n] for n in seen if n.startswith('bootstrap-') and n.endswith('.css'))
|
|
|
|
|
|
rules = lambda p: set(re.findall(r'[^{}]+\{[^{}]*\}', p.read_text(encoding='utf-8')))
|
|
a, b = rules(boot(sys.argv[1])), rules(boot(sys.argv[2]))
|
|
print('only in first:', sorted(a - b))
|
|
print('only in second:', sorted(b - a))
|