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
@@ -12,33 +12,37 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+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 *
from wiki2text import *
from wiki2texi import *
class DumpWikiMarkup (WikiMarkup):
def __str__(self):
if self.tree:
- s = StringIO.StringIO()
+ s = StringIO()
self.dump(self.tree, 0, s)
return s.getvalue()
else:
return ""
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)
handlers = {
'dump': {
'default': DumpWikiMarkup
},
@@ -106,16 +110,16 @@ def main():
if otype in handlers:
if itype in handlers[otype]:
markup = handlers[otype][itype](**kwdict)
markup.debug_level = debug
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)
if __name__ == '__main__':
main()

Return to:

Send suggestions and report system problems to the System administrator.