Moved import into Html5LibParser.__init__.

This commit is contained in:
Jannis Leidel
2012-03-03 23:33:44 +01:00
parent 9ff0d5871c
commit 422b672d13

View File

@@ -2,16 +2,16 @@ from __future__ import absolute_import
from django.utils.encoding import smart_unicode
from django.core.exceptions import ImproperlyConfigured
import html5lib
from compressor.exceptions import ParserError
from compressor.parser import ParserBase
from compressor.utils.decorators import cached_property
class Html5LibParser(ParserBase):
def __init__(self, content):
super(Html5LibParser, self).__init__(content)
import html5lib
self.html5lib = html5lib
def _serialize(self, elem):
@@ -28,7 +28,7 @@ class Html5LibParser(ParserBase):
@cached_property
def html(self):
try:
return html5lib.parseFragment(self.content)
return self.html5lib.parseFragment(self.content)
except ImportError, err:
raise ImproperlyConfigured("Error while importing html5lib: %s" % err)
except Exception, err: