mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fixed #1773: sphinx-quickstart doesn't accept non-ASCII character as a option argument.
This commit is contained in:
parent
502be7c26f
commit
b7547bb7fe
1
CHANGES
1
CHANGES
@ -6,6 +6,7 @@ Bugs fixed
|
|||||||
|
|
||||||
* #1769: allows generating quickstart files/dirs for destination dir that
|
* #1769: allows generating quickstart files/dirs for destination dir that
|
||||||
doesn't overwrite existent files/dirs. Thanks to WAKAYAMA shirou.
|
doesn't overwrite existent files/dirs. Thanks to WAKAYAMA shirou.
|
||||||
|
* #1773: sphinx-quickstart doesn't accept non-ASCII character as a option argument.
|
||||||
|
|
||||||
|
|
||||||
Release 1.3 (released Mar 10, 2015)
|
Release 1.3 (released Mar 10, 2015)
|
||||||
|
@ -28,7 +28,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from six import PY2, PY3, text_type
|
from six import PY2, PY3, text_type, binary_type
|
||||||
from six.moves import input
|
from six.moves import input
|
||||||
from six.moves.urllib.parse import quote as urlquote
|
from six.moves.urllib.parse import quote as urlquote
|
||||||
from docutils.utils import column_width
|
from docutils.utils import column_width
|
||||||
@ -1048,6 +1048,27 @@ def ok(x):
|
|||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
def term_decode(text):
|
||||||
|
if isinstance(text, text_type):
|
||||||
|
return text
|
||||||
|
|
||||||
|
# for Python 2.x, try to get a Unicode string out of it
|
||||||
|
if text.decode('ascii', 'replace').encode('ascii', 'replace') == text:
|
||||||
|
return text
|
||||||
|
|
||||||
|
if TERM_ENCODING:
|
||||||
|
text = text.decode(TERM_ENCODING)
|
||||||
|
else:
|
||||||
|
print(turquoise('* Note: non-ASCII characters entered '
|
||||||
|
'and terminal encoding unknown -- assuming '
|
||||||
|
'UTF-8 or Latin-1.'))
|
||||||
|
try:
|
||||||
|
text = text.decode('utf-8')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
text = text.decode('latin1')
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def do_prompt(d, key, text, default=None, validator=nonempty):
|
def do_prompt(d, key, text, default=None, validator=nonempty):
|
||||||
while True:
|
while True:
|
||||||
if default:
|
if default:
|
||||||
@ -1072,19 +1093,7 @@ def do_prompt(d, key, text, default=None, validator=nonempty):
|
|||||||
x = term_input(prompt).strip()
|
x = term_input(prompt).strip()
|
||||||
if default and not x:
|
if default and not x:
|
||||||
x = default
|
x = default
|
||||||
if not isinstance(x, text_type):
|
x = term_decode(x)
|
||||||
# for Python 2.x, try to get a Unicode string out of it
|
|
||||||
if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
|
|
||||||
if TERM_ENCODING:
|
|
||||||
x = x.decode(TERM_ENCODING)
|
|
||||||
else:
|
|
||||||
print(turquoise('* Note: non-ASCII characters entered '
|
|
||||||
'and terminal encoding unknown -- assuming '
|
|
||||||
'UTF-8 or Latin-1.'))
|
|
||||||
try:
|
|
||||||
x = x.decode('utf-8')
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
x = x.decode('latin1')
|
|
||||||
try:
|
try:
|
||||||
x = validator(x)
|
x = validator(x)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
@ -1551,6 +1560,12 @@ def main(argv=sys.argv):
|
|||||||
print()
|
print()
|
||||||
print('[Interrupted.]')
|
print('[Interrupted.]')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# decode values in d if value is a Python string literal
|
||||||
|
for key, value in d.items():
|
||||||
|
if isinstance(value, binary_type):
|
||||||
|
d[key] = term_decode(value)
|
||||||
|
|
||||||
generate(d)
|
generate(d)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user