[library-web] Only import html5lib when needed



commit 67a91db4ab4d43e18215761139e3bf8d5bcb675e
Author: Frédéric Péters <fpeters 0d be>
Date:   Fri Apr 1 18:16:15 2011 +0530

    Only import html5lib when needed

 src/modtypes/gnomedocbook.py |    5 -----
 src/modtypes/gtkdoc.py       |    9 ++++-----
 src/modtypes/htmlfiles.py    |   10 +++++-----
 src/modtypes/mallard.py      |    5 -----
 src/overlay.py               |    5 +++++
 5 files changed, 14 insertions(+), 20 deletions(-)
---
diff --git a/src/modtypes/gnomedocbook.py b/src/modtypes/gnomedocbook.py
index ada1a3e..6423c96 100644
--- a/src/modtypes/gnomedocbook.py
+++ b/src/modtypes/gnomedocbook.py
@@ -31,11 +31,6 @@ try:
 except ImportError:
     import xml.etree.ElementTree as ET
 
-try:
-    import html5lib
-except ImportError:
-    html5lib = None
-
 import errors
 from base import DocModule
 
diff --git a/src/modtypes/gtkdoc.py b/src/modtypes/gtkdoc.py
index ded7e19..da43e1d 100644
--- a/src/modtypes/gtkdoc.py
+++ b/src/modtypes/gtkdoc.py
@@ -30,11 +30,6 @@ try:
 except ImportError:
     import xml.etree.ElementTree as ET
 
-try:
-    import html5lib
-except ImportError:
-    html5lib = None
-
 from base import DocModule
 
 
@@ -114,6 +109,10 @@ class GtkDocModule(DocModule):
                         # documentation, can't do anything here :/
                         logging.error('skipped %s as it is missing an html/ dir' % doc_module)
                         return
+                    try:
+                        import html5lib
+                    except ImportError:
+                        html5lib = None
                     if html5lib:
                         # convert files to XML, then process them with xsltproc
                         # to get library.gnome.org look
diff --git a/src/modtypes/htmlfiles.py b/src/modtypes/htmlfiles.py
index 1700874..605ac9a 100644
--- a/src/modtypes/htmlfiles.py
+++ b/src/modtypes/htmlfiles.py
@@ -24,11 +24,6 @@ import stat
 import subprocess
 import tempfile
 
-try:
-    import html5lib
-except ImportError:
-    html5lib = None
-
 from base import DocModule
 
 class HtmlFilesModule(DocModule):
@@ -77,6 +72,11 @@ class HtmlFilesModule(DocModule):
         else:
             logging.info('generating doc in %s' % web_output_dir[len(app.config.output_dir):])
 
+            try:
+                import html5lib
+            except ImportError:
+                html5lib = None
+
             if html5lib:
                 # convert files to XML, then process them with xsltproc
                 # to get library.gnome.org look
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index 96fc21e..a9e3ed8 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -31,11 +31,6 @@ try:
 except ImportError:
     import xml.etree.ElementTree as ET
 
-try:
-    import html5lib
-except ImportError:
-    html5lib = None
-
 import xml.parsers.expat
 
 import errors
diff --git a/src/overlay.py b/src/overlay.py
index e1d9de0..433e066 100644
--- a/src/overlay.py
+++ b/src/overlay.py
@@ -116,6 +116,11 @@ class Overlay:
             self.quirks[(quirks.attrib['doc_module'], quirks.attrib['channel'])] = quirks
 
     def create_extra_wiki_docs(self):
+        try:
+            import html5lib
+        except ImportError:
+            logging.error('failed to import html5lib, skipping extra wiki docs')
+            return
         documents_node = self.tree.find('documents')
         for extra in self.tree.findall('/documents/extrawikidocs'):
             href = extra.find('href').text



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]