1. andrea_crotti
  2. tinkerer

Commits

andrea_crotti  committed 58ac725

add a function that looks for the root directory automatically

  • Participants
  • Parent commits 1c240ad
  • Branches default

Comments (0)

Files changed (1)

File tinkerer/utils.py

View file
  • Ignore whitespace
         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