"""Quick-and-dirty HTML minimizer""" import sys import re import html.entities import itertools _SERVERS = ['a.wearehugh.com', 'b.wearehugh.com', 'c.wearehugh.com', 'd.wearehugh.com'] available_server = itertools.cycle(_SERVERS) input_file = sys.argv[1] output_file = sys.argv[2] in_pre = False with open(output_file, 'w', encoding="utf-8") as _out, open(input_file, encoding="utf-8") as _in: for line in _in: # round-robin image servers if " blocks g = line.strip() if g.count('
 in one line
            in_pre = False
            g = line.rstrip()
        if in_pre:
            _out.write(line)
        else:
            _out.write(g)