diff options
-rw-r--r-- | wiki2html.py | 10 | ||||
-rw-r--r-- | wiki2texi.py | 9 | ||||
-rw-r--r-- | wiki2text.py | 3 | ||||
-rwxr-xr-x | wikicvt.py | 22 | ||||
-rw-r--r-- | wikimarkup.py | 5 |
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 @@ -18,6 +18,8 @@ from wikimarkup import * -from types import TupleType from wikins import wiki_ns_re, wiki_ns import re -import urllib +try: + from urllib import quote as url_quote +except ImportError: + from urllib.parse import quote as url_quote @@ -50,3 +52,3 @@ class HtmlWikiMarkup (WikiMarkup): lang = self.lang - return self.html_base % { 'lang' : lang } + urllib.quote(tgt) + return self.html_base % { 'lang' : lang } + url_quote(tgt) @@ -86,3 +88,3 @@ class HtmlWikiMarkup (WikiMarkup): if len(elt['content']) > 1: - s = map(self.format, elt['content']) + s = [x for x in map(self.format, elt['content'])] if s[0] == 'disambigR' or s[0] == 'wikiquote': diff --git a/wiki2texi.py b/wiki2texi.py index a7b5e92..6e32c56 100644 --- a/wiki2texi.py +++ b/wiki2texi.py @@ -18,3 +18,2 @@ from wikimarkup import * -from types import TupleType from wikins import wiki_ns_re, wiki_ns @@ -60,5 +59,5 @@ class TexiWikiMarkup (WikiMarkup): super(TexiWikiMarkup, self).__init__(*args, **keywords) - if keywords.has_key("sectioning-model"): + if "sectioning-model" in keywords: val = keywords["sectioning-model"] - if self.sectcomm.has_key(val): + if val in self.sectcomm: self.sectioning_model = val @@ -66,3 +65,3 @@ class TexiWikiMarkup (WikiMarkup): raise ValueError("Invalid value for sectioning model: %s" % val) - if keywords.has_key("sectioning-start"): + if "sectioning-start" in keywords: val = keywords["sectioning-start"] @@ -219,3 +218,3 @@ class TexiWikiMarkup (WikiMarkup): if len(elt['content']) > 1: - s = map(self.format, elt['content']) + s = [x for x in map(self.format, elt['content'])] text = s[1] diff --git a/wiki2text.py b/wiki2text.py index 6308da1..916391e 100644 --- a/wiki2text.py +++ b/wiki2text.py @@ -18,3 +18,2 @@ from wikimarkup import * -from types import TupleType from wikins import wiki_ns_re, wiki_ns @@ -70,3 +69,3 @@ class TextWikiMarkup (WikiMarkup): if len(elt['content']) > 1: - s = map(self.format, elt['content']) + s = [x for x in map(self.format, elt['content'])] text = s[1] @@ -17,5 +17,9 @@ +from __future__ import print_function import sys import getopt -import StringIO +try: + from StringIO import StringIO +except ImportError: + from io import StringIO from wiki2html import * @@ -27,3 +31,3 @@ class DumpWikiMarkup (WikiMarkup): if self.tree: - s = StringIO.StringIO() + s = StringIO() self.dump(self.tree, 0, s) @@ -34,6 +38,6 @@ class DumpWikiMarkup (WikiMarkup): def usage(code=0): - print """ -usage: %s [-hvt] [-I INTYPE] [-l lang] [-o kw=val] [--lang=lang] [--option kw=val] - [--input-type=INTYPE] [--type=OUTTYPE] [--help] [--verbose] file -""" % (sys.argv[0]) + print("""usage: %s [-hvt] [-I INTYPE] [-l lang] [-o kw=val] [--lang=lang] + [--option kw=val] [--input-type=INTYPE] [--type=OUTTYPE] [--help] + [--verbose] file +""" % sys.argv[0]) sys.exit(code) @@ -111,8 +115,8 @@ def main(): markup.parse() - print str(markup) + print("%s" % str(markup)) exit(0) else: - print "unsupported input type: %s" % (itype) + print("unsupported input type: %s" % itype) else: - print "unsupported output type: %s" % (otype) + print("unsupported output type: %s" % otype) exit(1) diff --git a/wikimarkup.py b/wikimarkup.py index adaa1a2..2ef6be1 100644 --- a/wikimarkup.py +++ b/wikimarkup.py @@ -17,2 +17,3 @@ +from __future__ import print_function import sys @@ -117,3 +118,3 @@ class BaseWikiMarkup(object): if self.debug_level >= lev: - print "[DEBUG]", fmt % argv + print("[DEBUG]", fmt % argv) @@ -995,3 +996,3 @@ class WikiMarkup (BaseWikiMarkup): "glk": "گیلکی", - "got": "𐌲𐌹𐌺 ", + "got": "𐌲𐌿𐍄𐌹𐍃𐌺𐍉𐍂𐌰𐌶𐌳𐌰", "gn": "Avañe'ẽ", # Guarani |