Commits

andrea_crotti committed 58ac725

add a function that looks for the root directory automatically

Comments (0)

Files changed (1)

tinkerer/utils.py

         date = datetime.datetime.today()
 
     return date.strftime("%Y/%m/%d").split("/")
+
+
+def find_project_root():
+    to_lookup = 'conf.py'
+
+    while True:
+        if os.path.isfile(to_lookup):
+            return os.path.abspath(os.path.dirname(to_lookup))
+        else:
+            new_val = os.path.abspath(os.path.join('..', to_lookup))
+            if new_val == to_lookup:
+                break
+            else:
+                to_lookup = new_val