summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--wiki2html.py10
-rw-r--r--wiki2texi.py9
-rw-r--r--wiki2text.py3
-rwxr-xr-xwikicvt.py22
-rw-r--r--wikimarkup.py5
5 files changed, 27 insertions, 22 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':
diff --git a/wiki2texi.py b/wiki2texi.py
index a7b5e92..6e32c56 100644
--- a/wiki2texi.py
+++ b/wiki2texi.py
@@ -16,7 +16,6 @@
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 21import urllib
@@ -58,13 +57,13 @@ class TexiWikiMarkup (WikiMarkup):
58 57
59 def __init__(self, *args, **keywords): 58 def __init__(self, *args, **keywords):
60 super(TexiWikiMarkup, self).__init__(*args, **keywords) 59 super(TexiWikiMarkup, self).__init__(*args, **keywords)
61 if keywords.has_key("sectioning-model"): 60 if "sectioning-model" in keywords:
62 val = keywords["sectioning-model"] 61 val = keywords["sectioning-model"]
63 if self.sectcomm.has_key(val): 62 if val in self.sectcomm:
64 self.sectioning_model = val 63 self.sectioning_model = val
65 else: 64 else:
66 raise ValueError("Invalid value for sectioning model: %s" % val) 65 raise ValueError("Invalid value for sectioning model: %s" % val)
67 if keywords.has_key("sectioning-start"): 66 if "sectioning-start" in keywords:
68 val = keywords["sectioning-start"] 67 val = keywords["sectioning-start"]
69 if val < 0 or val > 4: 68 if val < 0 or val > 4:
70 raise ValueError("Invalid value for sectioning start: %s" % val) 69 raise ValueError("Invalid value for sectioning start: %s" % val)
@@ -217,7 +216,7 @@ class TexiWikiMarkup (WikiMarkup):
217 # FIXME: A very crude version 216 # FIXME: A very crude version
218 arg = self.format(elt['content'][0]) 217 arg = self.format(elt['content'][0])
219 if len(elt['content']) > 1: 218 if len(elt['content']) > 1:
220 s = map(self.format, elt['content']) 219 s = [x for x in map(self.format, elt['content'])]
221 text = s[1] 220 text = s[1]
222 else: 221 else:
223 s = None 222 s = None
diff --git a/wiki2text.py b/wiki2text.py
index 6308da1..916391e 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -16,7 +16,6 @@
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 21import urllib
@@ -68,7 +67,7 @@ class TextWikiMarkup (WikiMarkup):
68 def fmtlink(self, elt, istmpl): 67 def fmtlink(self, elt, istmpl):
69 arg = self.format(elt['content'][0]) 68 arg = self.format(elt['content'][0])
70 if len(elt['content']) > 1: 69 if len(elt['content']) > 1:
71 s = map(self.format, elt['content']) 70 s = [x for x in map(self.format, elt['content'])]
72 text = s[1] 71 text = s[1]
73 else: 72 else:
74 s = None 73 s = None
diff --git a/wikicvt.py b/wikicvt.py
index c8ca887..41bba2f 100755
--- a/wikicvt.py
+++ b/wikicvt.py
@@ -15,9 +15,13 @@
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
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 __future__ import print_function
18import sys 19import sys
19import getopt 20import getopt
20import StringIO 21try:
22 from StringIO import StringIO
23except ImportError:
24 from io import StringIO
21from wiki2html import * 25from wiki2html import *
22from wiki2text import * 26from wiki2text import *
23from wiki2texi import * 27from wiki2texi import *
@@ -25,17 +29,17 @@ from wiki2texi import *
25class DumpWikiMarkup (WikiMarkup): 29class DumpWikiMarkup (WikiMarkup):
26 def __str__(self): 30 def __str__(self):
27 if self.tree: 31 if self.tree:
28 s = StringIO.StringIO() 32 s = StringIO()
29 self.dump(self.tree, 0, s) 33 self.dump(self.tree, 0, s)
30 return s.getvalue() 34 return s.getvalue()
31 else: 35 else:
32 return "" 36 return ""
33 37
34def usage(code=0): 38def usage(code=0):
35 print """ 39 print("""usage: %s [-hvt] [-I INTYPE] [-l lang] [-o kw=val] [--lang=lang]
36usage: %s [-hvt] [-I INTYPE] [-l lang] [-o kw=val] [--lang=lang] [--option kw=val] 40 [--option kw=val] [--input-type=INTYPE] [--type=OUTTYPE] [--help]
37 [--input-type=INTYPE] [--type=OUTTYPE] [--help] [--verbose] file 41 [--verbose] file
38""" % (sys.argv[0]) 42""" % sys.argv[0])
39 sys.exit(code) 43 sys.exit(code)
40 44
41handlers = { 45handlers = {
@@ -109,12 +113,12 @@ def main():
109 markup = handlers[otype][itype](**kwdict) 113 markup = handlers[otype][itype](**kwdict)
110 markup.debug_level = debug 114 markup.debug_level = debug
111 markup.parse() 115 markup.parse()
112 print str(markup) 116 print("%s" % str(markup))
113 exit(0) 117 exit(0)
114 else: 118 else:
115 print "unsupported input type: %s" % (itype) 119 print("unsupported input type: %s" % itype)
116 else: 120 else:
117 print "unsupported output type: %s" % (otype) 121 print("unsupported output type: %s" % otype)
118 exit(1) 122 exit(1)
119 123
120if __name__ == '__main__': 124if __name__ == '__main__':
diff --git a/wikimarkup.py b/wikimarkup.py
index adaa1a2..2ef6be1 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -15,6 +15,7 @@
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
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 __future__ import print_function
18import sys 19import sys
19import re 20import re
20from types import * 21from types import *
@@ -115,7 +116,7 @@ class BaseWikiMarkup(object):
115 116
116 def dprint(self, lev, fmt, *argv): 117 def dprint(self, lev, fmt, *argv):
117 if self.debug_level >= lev: 118 if self.debug_level >= lev:
118 print "[DEBUG]", fmt % argv 119 print("[DEBUG]", fmt % argv)
119 120
120 def print_dump_prefix(self, level, file): 121 def print_dump_prefix(self, level, file):
121 file.write("[DUMP]" + ' ' * (2*level + 1)) 122 file.write("[DUMP]" + ' ' * (2*level + 1))
@@ -993,7 +994,7 @@ class WikiMarkup (BaseWikiMarkup):
993 "gd": "Gàidhlig", # Scots; Gaelic 994 "gd": "Gàidhlig", # Scots; Gaelic
994 "gl": "Gallego" , # Gallegan; Galician 995 "gl": "Gallego" , # Gallegan; Galician
995 "glk": "گیلکی", 996 "glk": "گیلکی",
996 "got": "𐌲𐌹𐌺 ", 997 "got": "𐌲𐌿𐍄𐌹𐍃𐌺𐍉𐍂𐌰𐌶𐌳𐌰",
997 "gn": "Avañe'ẽ", # Guarani 998 "gn": "Avañe'ẽ", # Guarani
998 "g": "ગુજરાતી", # Gujarati 999 "g": "ગુજરાતી", # Gujarati
999 "gv": "Gaelg", # Manx 1000 "gv": "Gaelg", # Manx

Return to:

Send suggestions and report system problems to the System administrator.