summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-08-04 22:29:21 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-08-04 22:30:13 +0300
commit1fb7bc5aefaebf830b969c418f7987f50f4187f7 (patch)
treee7e8e1ec9ff165a7324b526815f8a9937ec0784b
parent0f45f681cf167c6259d8a8aafb7c58c25156bde0 (diff)
downloadwikitrans-1fb7bc5aefaebf830b969c418f7987f50f4187f7.tar.gz
wikitrans-1fb7bc5aefaebf830b969c418f7987f50f4187f7.tar.bz2
wikitrans: fixes
* bin/wikitrans (getwiki): fix downloading for Python 2.7 Return a properly encoded string. Fix help output. Allow to use -t dump with -I wiktionary
-rwxr-xr-xbin/wikitrans16
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/wikitrans b/bin/wikitrans
index ffbc048..c2ed4d3 100755
--- a/bin/wikitrans
+++ b/bin/wikitrans
@@ -34,3 +34,3 @@ from WikiTrans.wikidump import DumpWikiMarkup
-# Set utf-8 as the default encoding.
+# Set utf-8 as the default encoding for Python 2.7.
# Trying to do so using encode('utf_8')/unicode, which is
@@ -49,3 +49,4 @@ handlers = {
'dump': {
- 'default': DumpWikiMarkup
+ 'default': DumpWikiMarkup,
+ 'wiktionary': DumpWikiMarkup
},
@@ -79,4 +80,3 @@ def getwiki(url):
import urllib
- u = urllib.URLopener()
- u.retrieve(url, tmp.name)
+ urllib.urlretrieve(url, tmp.name)
root = etree.parse(tmp.name).getroot()
@@ -89,3 +89,3 @@ def getwiki(url):
exit(0)
- return text.text
+ return text.text.encode()
@@ -113,3 +113,3 @@ Otherwise, ARG is name of the file to read wiki material from.
default='default',
- help='set input document type')
+ help='set input document type ("default" or "wiktionary")')
parser.add_option('-t', '--to', '--type',
@@ -117,3 +117,3 @@ Otherwise, ARG is name of the file to read wiki material from.
default='html',
- help='set output document type')
+ help='set output document type ("html" (default), "texi" or "text")')
parser.add_option('-l', '--lang',
@@ -165,3 +165,3 @@ Otherwise, ARG is name of the file to read wiki material from.
else:
- print("unsupported input type: %s" % options.itype)
+ print("input type %s is not supported for %s output" % (options.itype, options.otype))
else:

Return to:

Send suggestions and report system problems to the System administrator.