File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+ from typing import Optional
3
+
4
+
5
+ def find_tdp_lib_root_folder (current_path : Optional [Path ] = None ):
6
+ # If current_path is not provided, start from the directory of this file
7
+ if current_path is None :
8
+ current_path = Path (__file__ ).parent
9
+
10
+ while True :
11
+ # Check if 'pyproject.toml' exists in the current directory
12
+ if (current_path / "pyproject.toml" ).exists ():
13
+ return current_path .resolve ()
14
+
15
+ parent_path = current_path .parent
16
+ # If the parent path is the same as the current path, we have reached the root directory
17
+ if parent_path == current_path :
18
+ return None
19
+
20
+ current_path = parent_path
21
+
22
+
23
+ if __name__ == "__main__" :
24
+ print (find_tdp_lib_root_folder ())
You can’t perform that action at this time.
0 commit comments