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