Skip to content

Commit

Permalink
Use setdefault instead of defaultdict to be compatible with older ver…
Browse files Browse the repository at this point in the history
…sions of Python (<2.5).
  • Loading branch information
jezdez committed Feb 23, 2010
1 parent 55acb2d commit 36fc377
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compressor/__init__.py
@@ -1,5 +1,4 @@
import os
from collections import defaultdict
from BeautifulSoup import BeautifulSoup

from django import template
Expand Down Expand Up @@ -153,7 +152,7 @@ def split_contents(self):
if self.split_content:
return self.split_content
split = self.soup.findAll({'link' : True, 'style' : True})
self.by_media = defaultdict(curry(CssCompressor, content=''))
self.by_media = {}
for elem in split:
data = None
if elem.name == 'link' and elem['rel'] == 'stylesheet':
Expand All @@ -166,7 +165,8 @@ def split_contents(self):
data = ('hunk', elem.string, elem)
if data:
self.split_content.append(data)
self.by_media[elem.get('media', None)].split_content.append(data)
self.by_media.setdefault(elem.get('media', None),
CssCompressor(content='')).split_content.append(data)
return self.split_content

def output(self):
Expand Down

0 comments on commit 36fc377

Please sign in to comment.