diff options
| author | Mathieu Pillard <m@virgule.net> | 2014-05-20 00:27:54 +0200 |
|---|---|---|
| committer | Mathieu Pillard <m@virgule.net> | 2014-05-20 00:27:54 +0200 |
| commit | e747dce3d7e04fe595bbfed54f9554c2725eb757 (patch) | |
| tree | f2c2e310e48062893f8224e08364bbff043afd84 /compressor/parser/default_htmlparser.py | |
| parent | 772ecd1ef2ce021d05cbc44eb8602f7d59db2c52 (diff) | |
| parent | 804c302495bd9d043f830ed012c76183eb5a1e2d (diff) | |
| download | django-compressor-1.4.tar.gz | |
Merge branch 'release/1.4'1.4
Diffstat (limited to 'compressor/parser/default_htmlparser.py')
| -rw-r--r-- | compressor/parser/default_htmlparser.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compressor/parser/default_htmlparser.py b/compressor/parser/default_htmlparser.py index 8425d77..80272cb 100644 --- a/compressor/parser/default_htmlparser.py +++ b/compressor/parser/default_htmlparser.py @@ -1,13 +1,13 @@ -from HTMLParser import HTMLParser -from django.utils.encoding import smart_unicode +from django.utils import six +from django.utils.encoding import smart_text + from compressor.exceptions import ParserError from compressor.parser import ParserBase -class DefaultHtmlParser(ParserBase, HTMLParser): - +class DefaultHtmlParser(ParserBase, six.moves.html_parser.HTMLParser): def __init__(self, content): - HTMLParser.__init__(self) + six.moves.html_parser.HTMLParser.__init__(self) self.content = content self._css_elems = [] self._js_elems = [] @@ -15,7 +15,7 @@ class DefaultHtmlParser(ParserBase, HTMLParser): try: self.feed(self.content) self.close() - except Exception, err: + except Exception as err: lineno = err.lineno line = self.content.splitlines()[lineno] raise ParserError("Error while initializing HtmlParser: %s (line: %s)" % (err, repr(line))) @@ -65,7 +65,7 @@ class DefaultHtmlParser(ParserBase, HTMLParser): return elem['attrs_dict'] def elem_content(self, elem): - return smart_unicode(elem['text']) + return smart_text(elem['text']) def elem_str(self, elem): tag = {} |
