@@ -11,7 +11,7 @@ def find_full_path(root_directories, relative_path):
1111 from provided potential root directories (in the given order)
1212 :param root_directories: potential root directories
1313 :param relative_path: the relative path to find the valid root directory
14- :return: root_directory
14+ :return: root_directory (pathlib.Path object)
1515 """
1616 relative_path = pathlib .Path (relative_path )
1717
@@ -36,7 +36,7 @@ def find_root_directory(root_directories, full_path):
3636 search and return one directory that is the parent of the given path
3737 :param root_directories: potential root directories
3838 :param full_path: the relative path to search the root directory
39- :return: full-path
39+ :return: full-path (pathlib.Path object)
4040 """
4141 full_path = pathlib .Path (full_path )
4242
@@ -48,8 +48,9 @@ def find_root_directory(root_directories, full_path):
4848 root_directories = [root_directories ]
4949
5050 try :
51- return next (root_dir for root_dir in root_directories
52- if full_path .is_relative_to (root_dir ))
51+ return next (pathlib .Path (root_dir ) for root_dir in root_directories
52+ if pathlib .Path (root_dir ) in set (full_path .parents ))
53+
5354 except StopIteration :
5455 raise FileNotFoundError ('No valid root directory found (from {})'
5556 ' for {}' .format (root_directories , full_path ))
0 commit comments