use multi-platform os.sep

This commit is contained in:
2014-12-02 14:22:19 +01:00
parent 60f47d2d38
commit f7cf15e708

View File

@@ -137,11 +137,10 @@ class FPElem_sequence_single(FPElem):
def _set_cb(self, filepath): def _set_cb(self, filepath):
block, path, sub_block, sub_path = self.userdata block, path, sub_block, sub_path = self.userdata
# TODO, os.sep head, sep, tail = utils.splitpath(filepath)
a, b = filepath.rsplit(b'/', 1)
block[path] = a + b'/' block[path] = head + sep
sub_block[sub_path] = b sub_block[sub_path] = tail
class FilePath: class FilePath:
@@ -700,3 +699,16 @@ class utils:
def compatpath(path): def compatpath(path):
# keep '//' # keep '//'
return path[:2] + path[2:].replace(b'/', b'\\') return path[:2] + path[2:].replace(b'/', b'\\')
@staticmethod
def splitpath(path):
"""
Splits the path using either slashes
"""
split1 = path.rpartition(b'/')
split2 = path.rpartition(b'\\')
if len(split1[0]) > len(split2[0]):
return split1
else:
return split2