assuming you got a list of margin/padding values from your css with
ack --css margin > margin.txt
ack --css padding > padding.txt
you can run
python scan.py
and get a list of the most popular padding and margin values
import os | |
import sys | |
import re | |
from collections import defaultdict, Counter | |
val_re = re.compile('(\d+(?:px|em|%)?|auto)') | |
def count_vals(filename): | |
with open(filename) as f: | |
db = defaultdict(int) | |
for line in f: | |
valstring = line.split(':')[-1].strip() | |
vals = re.findall(val_re, valstring) | |
for val in vals: | |
db[val] += 1 | |
return Counter(db) | |
def main(): | |
filenames = ['padding.txt', 'margin.txt'] | |
for filename in filenames: | |
count = count_vals(filename) | |
print filename | |
print count.most_common(15) | |
if __name__ == '__main__': | |
main() |