[library-web] only import hmtl5lib when needed for remote documents
- From: Frederic Peters <fpeters src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [library-web] only import hmtl5lib when needed for remote documents
 
- Date: Fri,  1 Apr 2011 15:32:07 +0000 (UTC)
 
commit 852eab57847f14eaa6f0bd6e83fb4f8b32c6260b
Author: Frédéric Péters <fpeters 0d be>
Date:   Fri Apr 1 21:01:38 2011 +0530
    only import hmtl5lib when needed for remote documents
 src/document.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/document.py b/src/document.py
index 3447383..0be04d4 100644
--- a/src/document.py
+++ b/src/document.py
@@ -26,11 +26,6 @@ try:
 except ImportError:
     import xml.etree.ElementTree as ET
 
-try:
-    import html5lib
-except ImportError:
-    html5lib = None
-
 from utils import version_cmp
 
 
@@ -217,6 +212,13 @@ class RemoteDocument(Document):
 
         mtime_xsl = os.stat(self.html2html_xsl_file)[stat.ST_MTIME]
 
+        try:
+            import html5lib
+        except ImportError:
+            logging.error('missing html5lib, unable to convert %s' % self.module)
+            html5lib = None
+            return
+
         for lang in self.href:
             if self.href[lang] == '-':
                 continue
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]