@@ -11,7 +11,7 @@ def find_full_path(root_directories, relative_path):
11
11
from provided potential root directories (in the given order)
12
12
:param root_directories: potential root directories
13
13
:param relative_path: the relative path to find the valid root directory
14
- :return: root_directory
14
+ :return: root_directory (pathlib.Path object)
15
15
"""
16
16
relative_path = pathlib .Path (relative_path )
17
17
@@ -36,7 +36,7 @@ def find_root_directory(root_directories, full_path):
36
36
search and return one directory that is the parent of the given path
37
37
:param root_directories: potential root directories
38
38
:param full_path: the relative path to search the root directory
39
- :return: full-path
39
+ :return: full-path (pathlib.Path object)
40
40
"""
41
41
full_path = pathlib .Path (full_path )
42
42
@@ -48,8 +48,9 @@ def find_root_directory(root_directories, full_path):
48
48
root_directories = [root_directories ]
49
49
50
50
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
+
53
54
except StopIteration :
54
55
raise FileNotFoundError ('No valid root directory found (from {})'
55
56
' for {}' .format (root_directories , full_path ))
0 commit comments