mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #856 from avaris/non-ascii-path
force argparse output to be unicode in Py2
This commit is contained in:
commit
13eeb9043a
1 changed files with 13 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
|
import locale
|
||||||
|
|
||||||
from pelican import signals
|
from pelican import signals
|
||||||
|
|
||||||
|
|
@ -274,6 +275,18 @@ def get_config(args):
|
||||||
config['THEME'] = abstheme if os.path.exists(abstheme) else args.theme
|
config['THEME'] = abstheme if os.path.exists(abstheme) else args.theme
|
||||||
if args.delete_outputdir is not None:
|
if args.delete_outputdir is not None:
|
||||||
config['DELETE_OUTPUT_DIRECTORY'] = args.delete_outputdir
|
config['DELETE_OUTPUT_DIRECTORY'] = args.delete_outputdir
|
||||||
|
|
||||||
|
# argparse returns bytes in Py2. There is no definite answer as to which
|
||||||
|
# encoding argparse (or sys.argv) uses.
|
||||||
|
# "Best" option seems to be locale.getpreferredencoding()
|
||||||
|
# ref: http://mail.python.org/pipermail/python-list/2006-October/405766.html
|
||||||
|
if not six.PY3:
|
||||||
|
enc = locale.getpreferredencoding()
|
||||||
|
for key in config:
|
||||||
|
if key in ('PATH', 'OUTPUT_PATH', 'THEME'):
|
||||||
|
config[key] = config[key].decode(enc)
|
||||||
|
if key == "MARKUP":
|
||||||
|
config[key] = [a.decode(enc) for a in config[key]]
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue