diff shrink

This commit is contained in:
Jean-Paul Calderone 2021-01-12 14:20:50 -05:00
parent aa4f113027
commit 46d3ffb2e2

View File

@ -96,6 +96,20 @@ def get_io_encoding():
"""
return io_encoding
def argv_to_unicode(s):
"""
Perform the inverse of ``unicode_to_argv``.
"""
if isinstance(s, unicode):
return s
precondition(isinstance(s, bytes), s)
try:
return unicode(s, io_encoding)
except UnicodeDecodeError:
raise usage.UsageError("Argument %s cannot be decoded as %s." %
(quote_output(s), io_encoding))
def argv_to_abspath(s, **kwargs):
"""
Convenience function to decode an argv element to an absolute path, with ~ expanded.
@ -119,20 +133,6 @@ def unicode_to_argv(s, mangle=False):
return ensure_str(s)
def argv_to_unicode(s):
"""
Perform the inverse of ``unicode_to_argv``.
"""
if isinstance(s, unicode):
return s
precondition(isinstance(s, bytes), s)
try:
return unicode(s, io_encoding)
except UnicodeDecodeError:
raise usage.UsageError("Argument %s cannot be decoded as %s." %
(quote_output(s), io_encoding))
def unicode_to_url(s):
"""
Encode an unicode object used in an URL to bytes.