diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-07-30 17:11:56 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-07-30 17:11:56 +0300 |
commit | 962837ceee4824e37590366ae6e64ba4293b5831 (patch) | |
tree | 7a4210aed3b86686ff014c65dc812e57516e1b3a | |
parent | 33911cd4ca1a0ef49b836900f21cd2df4e528f93 (diff) | |
download | wit-master.tar.gz wit-master.tar.bz2 |
* 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.
-rw-r--r-- | test.py | 2 | ||||
-rw-r--r-- | wiki2html.py | 4 | ||||
-rw-r--r-- | wiki2texi.py | 4 | ||||
-rw-r--r-- | wiki2text.py | 20 | ||||
-rw-r--r-- | wikimarkup.py | 2 |
5 files changed, 19 insertions, 13 deletions
@@ -16,6 +16,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function +import sys, os +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) import unittest import wiki2html diff --git a/wiki2html.py b/wiki2html.py index 05d4642..abf851a 100644 --- a/wiki2html.py +++ b/wiki2html.py @@ -15,8 +15,8 @@ # 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 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 try: from urllib import quote as url_quote diff --git a/wiki2texi.py b/wiki2texi.py index 6e32c56..4ce32f9 100644 --- a/wiki2texi.py +++ b/wiki2texi.py @@ -15,8 +15,8 @@ # 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 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 diff --git a/wiki2text.py b/wiki2text.py index 916391e..5041ea0 100644 --- a/wiki2text.py +++ b/wiki2text.py @@ -15,10 +15,14 @@ # 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 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 + class TextWikiMarkup (WikiMarkup): """ @@ -58,11 +62,11 @@ class TextWikiMarkup (WikiMarkup): if str.beginswith(elt[0]) and str.endswith(elt[1]): return elt[2] return None - + def mktgt(self, tgt, lang = None): if not lang: lang = self.lang - return self.html_base % { 'lang' : lang } + urllib.quote(tgt) + return self.html_base % { 'lang' : lang } + url_quote(tgt) def fmtlink(self, elt, istmpl): arg = self.format(elt['content'][0]) @@ -87,8 +91,8 @@ class TextWikiMarkup (WikiMarkup): return "" text = "[%s: %s]" % (qual, text if text else arg) tgt = self.image_base + '/' + \ - urllib.quote(tgt) + \ - '/250px-' + urllib.quote(tgt) + url_quote(tgt) + \ + '/250px-' + url_quote(tgt) elif ns == 'NS_MEDIA': text = "[%s]" % (qual) else: @@ -112,7 +116,7 @@ class TextWikiMarkup (WikiMarkup): s = (" " * lev) + text else: s = "" - for elt in text.split('\n'): + for elt in text.decode("utf-8").split('\n'): if elt: s += (" " * lev) + elt + '\n' if not text.endswith('\n'): diff --git a/wikimarkup.py b/wikimarkup.py index 2ef6be1..9371d89 100644 --- a/wikimarkup.py +++ b/wikimarkup.py @@ -853,7 +853,7 @@ class WikiMarkup (BaseWikiMarkup): elif kw == 'filename': self.file = open(keywords[kw]) elif kw == 'text': - self.text = keywords[kw].split("\n") + self.text = keywords[kw].decode("utf-8").split("\n") elif kw == 'lang': self.lang = keywords[kw] elif kw == 'html_base': |