aboutsummaryrefslogtreecommitdiff
path: root/wiki2html.py
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-07-16 00:12:35 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2015-07-16 00:12:35 +0300
commit45b2027439e96c366e188a12bd831802d30bbddc (patch)
tree4333fb83ed667b1000f3d6bf71bc11b44e76c468 /wiki2html.py
parent6f963022315d4306f50f2e7046f2872cfd3c0500 (diff)
downloadwit-45b2027439e96c366e188a12bd831802d30bbddc.tar.gz
wit-45b2027439e96c366e188a12bd831802d30bbddc.tar.bz2
Support for Python 3
* wiki2html.py: Import urllib.parse if importing urllib fails. Use list comprehensions to build lists from maps. * wiki2texi.py: Use 'in' instead of has_key. Use list comprehensions to build lists from maps. * wiki2text.py: Likewise. * wikicvt.py: Use print function. Import StringIO from io if unable to import is as a module * wikimarkup.py: Use print function. Fix some UTF strings.
Diffstat (limited to 'wiki2html.py')
-rw-r--r--wiki2html.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/wiki2html.py b/wiki2html.py
index 0330b92..05d4642 100644
--- a/wiki2html.py
+++ b/wiki2html.py
@@ -16,10 +16,12 @@
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18from wikimarkup import * 18from wikimarkup import *
19from types import TupleType
20from wikins import wiki_ns_re, wiki_ns 19from wikins import wiki_ns_re, wiki_ns
21import re 20import re
22import urllib 21try:
22 from urllib import quote as url_quote
23except ImportError:
24 from urllib.parse import quote as url_quote
23 25
24class HtmlWikiMarkup (WikiMarkup): 26class HtmlWikiMarkup (WikiMarkup):
25 """ 27 """
@@ -48,7 +50,7 @@ class HtmlWikiMarkup (WikiMarkup):
48 def mktgt(self, tgt, lang = None): 50 def mktgt(self, tgt, lang = None):
49 if not lang: 51 if not lang:
50 lang = self.lang 52 lang = self.lang
51 return self.html_base % { 'lang' : lang } + urllib.quote(tgt) 53 return self.html_base % { 'lang' : lang } + url_quote(tgt)
52 54
53 def tmpl_term(self, s): 55 def tmpl_term(self, s):
54 if len(s) == 2: 56 if len(s) == 2:
@@ -84,7 +86,7 @@ class HtmlWikiMarkup (WikiMarkup):
84 arg = self.format(elt['content'][0]) 86 arg = self.format(elt['content'][0])
85 text = None 87 text = None
86 if len(elt['content']) > 1: 88 if len(elt['content']) > 1:
87 s = map(self.format, elt['content']) 89 s = [x for x in map(self.format, elt['content'])]
88 if s[0] == 'disambigR' or s[0] == 'wikiquote': 90 if s[0] == 'disambigR' or s[0] == 'wikiquote':
89 return "" 91 return ""
90 elif len(s) > 1 and s[1] == 'thumb': 92 elif len(s) > 1 and s[1] == 'thumb':

Return to:

Send suggestions and report system problems to the System administrator.