def compress_css(css, combine_blocks=True, compress_whitespace=True, compress_color=True, compress_font=True, compress_dimension=True, sort_properties=True, tab='\t'): groups = parse_groups(css) options = dict(combine_blocks=combine_blocks, compress_whitespace=compress_whitespace, compress_color=compress_color, compress_font=compress_font, compress_dimension=compress_dimension, sort_properties=sort_properties, tab=tab) compressed_groups = [generate_group(selectors, blocks, **options) for selectors, blocks in groups] newlines = '' if compress_whitespace else '\n\n' return newlines.join(compressed_groups)
def assertParse(self, css, result): self.assertEqual(parse_groups(css), result)