X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8b2eb7d1fa47e4a691849a485573c5da79bb1e2e..76d560673ee770e55900143b96d32588905dc37a:/sdk/python/arvados/_normalize_stream.py diff --git a/sdk/python/arvados/_normalize_stream.py b/sdk/python/arvados/_normalize_stream.py index a119da2387..485c757e7f 100644 --- a/sdk/python/arvados/_normalize_stream.py +++ b/sdk/python/arvados/_normalize_stream.py @@ -8,11 +8,8 @@ from . import config import re def escape(path): - # Escape literal backslash path = re.sub('\\\\', lambda m: '\\134', path) - # Escape other special chars. Py3's oct() output differs from Py2, this takes - # care of those differences. - path = re.sub('([\t\n\r: ])', lambda m: '\\'+oct(ord(m.group(1))).replace('o', '')[-3:], path) + path = re.sub('[:\000-\040]', lambda m: "\\%03o" % ord(m.group(0)), path) return path def normalize_stream(stream_name, stream): @@ -58,13 +55,13 @@ def normalize_stream(stream_name, stream): if streamoffset == current_span[1]: current_span[1] += segment.segment_size else: - stream_tokens.append("{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) + stream_tokens.append(u"{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) current_span = [streamoffset, streamoffset + segment.segment_size] if current_span is not None: - stream_tokens.append("{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) + stream_tokens.append(u"{0}:{1}:{2}".format(current_span[0], current_span[1] - current_span[0], fout)) if not stream[streamfile]: - stream_tokens.append("0:0:{0}".format(fout)) + stream_tokens.append(u"0:0:{0}".format(fout)) return stream_tokens