Commit 04843037 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Compression methods now alter their argument instead of making a copy

parent 2737089c
from color import color_shortcut
def combine_blocks(blocks):
# Map of property stringification to list of containing blocks
#property_locations = {}
......@@ -5,13 +8,31 @@ def combine_blocks(blocks):
return blocks
def _filter_property(basename, properties):
prefix = basename + '-'
filtered = []
for prop in list(properties):
name, value = prop
if name == basename or name[:len(prefix)] == prefix:
filtered.append(properties.remove(prop))
return filtered
def compress_color(properties):
return properties
for i, (name, value) in enumerate(properties):
if name in ('color', 'background-color', 'border-color'):
properties[i] = (name, color_shortcut(value))
def compress_font(properties):
return properties
#fonts = _filter_property('font', properties)
pass
def compress_dimension(properties):
return properties
#margins = _filter_property('margin', properties)
#paddings = _filter_property('padding', properties)
pass
......@@ -70,13 +70,13 @@ def generate_group(selectors, blocks, combine_blocks=True,
for block_selectors, properties in blocks:
if compress_color:
properties = compress.compress_color(properties)
compress.compress_color(properties)
if compress_font:
properties = compress.compress_font(properties)
compress.compress_font(properties)
if compress_dimension:
properties = compress.compress_dimension(properties)
compress.compress_dimension(properties)
compressed_blocks.append(generate_block(block_selectors, properties,
compress_whitespace=compress_whitespace,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment