allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterhartm...@apache.org
Subject [3/3] git commit: [#4647] Make html2text import in ForgeWiki optional
Date Thu, 27 Dec 2012 23:12:06 GMT
Updated Branches:
  refs/heads/ph/4647 [created] 63be6b46f


[#4647] Make html2text import in ForgeWiki optional

Signed-off-by: Peter Hartmann <peterhartmann@apache.org>

Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4a127a06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4a127a06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4a127a06

Branch: refs/heads/ph/4647
Commit: 4a127a064f0dda4f7c952767d0ed6fc61a270f57
Parents: ae1c6ca
Author: Peter Hartmann <peterhartmann@apache.org>
Authored: Tue Dec 18 01:19:31 2012 +0100
Committer: Peter Hartmann <peterhartmann@apache.org>
Committed: Fri Dec 28 00:07:16 2012 +0100

----------------------------------------------------------------------
 ForgeWiki/forgewiki/converters.py |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4a127a06/ForgeWiki/forgewiki/converters.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/converters.py b/ForgeWiki/forgewiki/converters.py
index 3fcfc41..0fb6ad0 100644
--- a/ForgeWiki/forgewiki/converters.py
+++ b/ForgeWiki/forgewiki/converters.py
@@ -1,10 +1,7 @@
 #-*- python -*-
-import html2text
 import re
 from BeautifulSoup import BeautifulSoup
 
-html2text.BODY_WIDTH = 0
-
 _inline_img = re.compile(r'\[\[(File|Image):([^\]|]+)[^]]*\]\]', re.UNICODE)
 _inline_img_markdown = r'[[img src=\2]]'
 _link_to_attach = re.compile(r'\[\[Media:([^\]|]+)\|?([^]]*)\]\]', re.UNICODE)
@@ -44,11 +41,15 @@ def _convert_toc(wiki_html):
 
 def mediawiki2markdown(source):
     try:
+        import html2text
         from mediawiki import wiki2html
     except ImportError:
-        raise ImportError('GPL library "mediawiki" from https://github.com/zikzakmedia/python-mediawiki.git
'
-                                 'is required for this operation')
-
+        raise ImportError("""This operation requires GPL libraries:
+        "mediawiki" (https://github.com/zikzakmedia/python-mediawiki.git)
+        "html2text" (https://github.com/aaronsw/html2text.git)""")
+    
+    html2text.BODY_WIDTH = 0
+    
     wiki_content = wiki2html(source, True)
     wiki_content = _convert_toc(wiki_content)
     markdown_text = html2text.html2text(wiki_content)


Mime
View raw message