diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-08-04 22:29:21 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-08-04 22:30:13 +0300 |
commit | 1fb7bc5aefaebf830b969c418f7987f50f4187f7 (patch) | |
tree | e7e8e1ec9ff165a7324b526815f8a9937ec0784b | |
parent | 0f45f681cf167c6259d8a8aafb7c58c25156bde0 (diff) | |
download | wikitrans-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-x | bin/wikitrans | 16 |
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: |