filter-repo (python3): add a decode() function

We need a function to transform byte strings into unicode strings for
printing error messages and occasional other uses.

Signed-off-by: Elijah Newren <newren@gmail.com>
pull/13/head
Elijah Newren 5 years ago
parent 2562f0270c
commit 1a8e247ba7

@ -115,6 +115,10 @@ def date_to_string(dateobj):
return('{} {}'.format(int(_timedelta_to_seconds(dateobj - epoch)),
dateobj.tzinfo.tzname(0)))
def decode(bytestr):
'Try to convert bytestr to utf-8 for outputting as an error message.'
return bytestr.decode('utf-8', 'backslashreplace')
class PathQuoting:
_unescape = {'a': '\a',
'b': '\b',

Loading…
Cancel
Save