diff --git a/snakehouse/satella.py b/snakehouse/satella.py index 970813a1b8394b3a3a5379c795c47f6929dc1de4..58a64f7ff508d9addcadaa1d0e747a76eeddf5ff 100644 --- a/snakehouse/satella.py +++ b/snakehouse/satella.py @@ -6,6 +6,14 @@ snakehouse. import typing as tp +def _has_separator(path: str) -> bool: + # handle Windows case + if len(path) == 3: + if path.endswith(':/') or path.endswith(':\\'): + return False + return any(map(lambda x: x in path, SEPARATORS)) + + def find_files(path: str, wildcard: str = r'(.*)', prefix_with: tp.Optional[str] = None, scan_subdirectories: bool = True, @@ -57,9 +65,20 @@ def split(path: str) -> tp.List[str]: Is is true that + >>> os.path.join(split(a)) == a + """ + data = list(os.path.split(path)) + while _has_separdef split(path: str) -> tp.List[str]: + """ + An exact reverse of os.path.join + + Is is true that + >>> os.path.join(split(a)) == a """ data = list(os.path.split(path)) while _has_separator(data[0]): data = list(os.path.split(data[0])) + data[1:] + return dataator(data[0]): + data = list(os.path.split(data[0])) + data[1:] return data \ No newline at end of file