@@ -72,21 +72,19 @@ def log_and_raise_if_not_isdir(path_dir: pathlib.Path) -> None:
7272def 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
9795def 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