Skip to content

Commit dd87884

Browse files
committed
refractor
1 parent 23df174 commit dd87884

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

lib_path/lib_path.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,19 @@ def log_and_raise_if_not_isdir(path_dir: pathlib.Path) -> None:
7272
def log_and_raise_if_target_directory_within_source_directory(path_source_dir: pathlib.Path, path_target_dir: pathlib.Path) -> None:
7373
"""
7474
>>> # Setup
75-
>>> path_source_dir=pathlib.Path('./test')
76-
>>> path_target_dir_ok=pathlib.Path('./test2/test')
77-
>>> path_target_dir_err=pathlib.Path('./test/test2')
75+
>>> path_source_dir=pathlib.Path('/test')
76+
>>> path_target_dir_ok=pathlib.Path('/test2/test')
77+
>>> path_target_dir_err=pathlib.Path('/test/test2')
78+
79+
>>> # Test OK
80+
>>> log_and_raise_if_target_directory_within_source_directory(path_source_dir, path_target_dir_ok)
7881
7982
>>> # Test ERR
8083
>>> log_and_raise_if_target_directory_within_source_directory(path_source_dir, path_target_dir_err)
8184
Traceback (most recent call last):
8285
...
8386
FileExistsError: target directory: "..." is within the source directory "..."
8487
85-
86-
>>> # Test OK
87-
>>> log_and_raise_if_target_directory_within_source_directory(path_source_dir, path_target_dir_ok)
88-
89-
9088
"""
9189
if is_target_directory_within_source_directory(path_source_dir, path_target_dir):
9290
s_error = 'target directory: "{}" is within the source directory "{}"'.format(path_target_dir, path_source_dir)
@@ -95,9 +93,8 @@ def log_and_raise_if_target_directory_within_source_directory(path_source_dir: p
9593

9694

9795
def is_target_directory_within_source_directory(path_source_dir: pathlib.Path, path_target_dir: pathlib.Path) -> bool:
98-
s_source_dir = str(path_source_dir.resolve()) + '/'
99-
s_target_dir = str(path_target_dir.resolve()) + '/'
100-
logger.error('S:' + s_source_dir + ' T:' + s_target_dir)
96+
s_source_dir = str(path_source_dir.resolve()).replace('\\', '/') + '/'
97+
s_target_dir = str(path_target_dir.resolve()).replace('\\', '/') + '/'
10198
if s_target_dir.startswith(s_source_dir):
10299
return True
103100
else:

0 commit comments

Comments
 (0)