summaryrefslogtreecommitdiff
path: root/compressor/parser/default_htmlparser.py
diff options
context:
space:
mode:
authorMathieu Pillard <m@virgule.net>2014-05-20 00:27:54 +0200
committerMathieu Pillard <m@virgule.net>2014-05-20 00:27:54 +0200
commite747dce3d7e04fe595bbfed54f9554c2725eb757 (patch)
treef2c2e310e48062893f8224e08364bbff043afd84 /compressor/parser/default_htmlparser.py
parent772ecd1ef2ce021d05cbc44eb8602f7d59db2c52 (diff)
parent804c302495bd9d043f830ed012c76183eb5a1e2d (diff)
downloaddjango-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.py14
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 = {}