summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-07-30 14:11:56 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-07-30 14:11:56 (GMT)
commit962837ceee4824e37590366ae6e64ba4293b5831 (patch) (side-by-side diff)
tree7a4210aed3b86686ff014c65dc812e57516e1b3a
parent33911cd4ca1a0ef49b836900f21cd2df4e528f93 (diff)
downloadwit-master.tar.gz
wit-master.tar.bz2
Fix Python 3 compatibilityHEADmaster
* test.py: Prepend parent dir to the sys.path * wiki2html.py: Use absolute imports * wiki2texi.py: Likewise. * wiki2text.py: Likewise. (url_quote): Import from the appropriate module. * wikimarkup.py: Make sure the object being split is a string.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--test.py2
-rw-r--r--wiki2html.py4
-rw-r--r--wiki2texi.py4
-rw-r--r--wiki2text.py18
-rw-r--r--wikimarkup.py2
5 files changed, 18 insertions, 12 deletions
diff --git a/test.py b/test.py
index 9c72832..a348bc1 100644
--- a/test.py
+++ b/test.py
@@ -18,2 +18,4 @@
from __future__ import print_function
+import sys, os
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
import unittest
diff --git a/wiki2html.py b/wiki2html.py
index 05d4642..abf851a 100644
--- a/wiki2html.py
+++ b/wiki2html.py
@@ -17,4 +17,4 @@
-from wikimarkup import *
-from wikins import wiki_ns_re, wiki_ns
+from wit.wikimarkup import *
+from wit.wikins import wiki_ns_re, wiki_ns
import re
diff --git a/wiki2texi.py b/wiki2texi.py
index 6e32c56..4ce32f9 100644
--- a/wiki2texi.py
+++ b/wiki2texi.py
@@ -17,4 +17,4 @@
-from wikimarkup import *
-from wikins import wiki_ns_re, wiki_ns
+from wit.wikimarkup import *
+from wit.wikins import wiki_ns_re, wiki_ns
import re
diff --git a/wiki2text.py b/wiki2text.py
index 916391e..5041ea0 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -17,6 +17,10 @@
-from wikimarkup import *
-from wikins import wiki_ns_re, wiki_ns
+from wit.wikimarkup import *
+from wit.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
+
@@ -64,3 +68,3 @@ class TextWikiMarkup (WikiMarkup):
lang = self.lang
- return self.html_base % { 'lang' : lang } + urllib.quote(tgt)
+ return self.html_base % { 'lang' : lang } + url_quote(tgt)
@@ -89,4 +93,4 @@ class TextWikiMarkup (WikiMarkup):
tgt = self.image_base + '/' + \
- urllib.quote(tgt) + \
- '/250px-' + urllib.quote(tgt)
+ url_quote(tgt) + \
+ '/250px-' + url_quote(tgt)
elif ns == 'NS_MEDIA':
@@ -114,3 +118,3 @@ class TextWikiMarkup (WikiMarkup):
s = ""
- for elt in text.split('\n'):
+ for elt in text.decode("utf-8").split('\n'):
if elt:
diff --git a/wikimarkup.py b/wikimarkup.py
index 2ef6be1..9371d89 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -855,3 +855,3 @@ class WikiMarkup (BaseWikiMarkup):
elif kw == 'text':
- self.text = keywords[kw].split("\n")
+ self.text = keywords[kw].decode("utf-8").split("\n")
elif kw == 'lang':

Return to:

Send suggestions and report system problems to the System administrator.