summaryrefslogtreecommitdiff
path: root/wikicvt.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 /wikicvt.py
parent6f963022315d4306f50f2e7046f2872cfd3c0500 (diff)
downloadwikitrans-45b2027439e96c366e188a12bd831802d30bbddc.tar.gz
wikitrans-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 'wikicvt.py')
-rwxr-xr-xwikicvt.py22
1 files changed, 13 insertions, 9 deletions
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__':

Return to:

Send suggestions and report system problems to the System administrator.