Merge branch '18363-managed-properties-doc-improvement' into main.
[arvados.git] / sdk / python / arvados / _normalize_stream.py
index 9b29e8804607f17dfff2adca35d0a44b99f2b6d6..485c757e7fce34dda579185608f39bfe4911bd94 100644 (file)
@@ -8,12 +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(
-        '([:\000-\040])', lambda m: "\\%03o" % ord(m.group(1)), path)
+    path = re.sub('[:\000-\040]', lambda m: "\\%03o" % ord(m.group(0)), path)
     return path
 
 def normalize_stream(stream_name, stream):
@@ -59,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