Merge pull request #5 from jwilk-forks/encoding

Decode article name with locale encoding
This commit is contained in:
Dan Lenski 2019-06-04 09:30:18 -07:00 committed by GitHub
commit fa546f7b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import urlparse
import os, locale, time import os, locale, time
from .version import __version__ from .version import __version__
locale_encoding = locale.getpreferredencoding()
lang = locale.getdefaultlocale()[0].split('_')[0] or '' lang = locale.getdefaultlocale()[0].split('_')[0] or ''
def sanitize(s): def sanitize(s):
@ -66,7 +67,7 @@ def main():
print('Connected to %s://%s%s' % (scheme, host, path), file=stderr) print('Connected to %s://%s%s' % (scheme, host, path), file=stderr)
# Find the page # Find the page
page = site.pages[args.article_name] page = site.pages[args.article_name.decode(locale_encoding)]
if not page.exists: if not page.exists:
p.error('Page %s does not exist' % args.article_name) p.error('Page %s does not exist' % args.article_name)
fn = sanitize(args.article_name) fn = sanitize(args.article_name)