diff piecrust/pathutil.py @ 0:a212a3f2e3ee

Initial commit.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 21 Dec 2013 14:44:02 -0800
parents
children aaa8fb7c8918
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/pathutil.py	Sat Dec 21 14:44:02 2013 -0800
@@ -0,0 +1,23 @@
+import os
+import os.path
+
+
+class SiteNotFoundError(Exception):
+    def __init__(self, root=None):
+        if not root:
+            root = os.getcwd()
+        Exception.__init__(self,
+                "No PieCrust website in '%s' "
+                "('_content/config.yml' not found!)." % root)
+
+
+def find_app_root(cwd=None):
+    if cwd is None:
+        cwd = os.getcwd()
+
+    while not os.path.isfile(os.path.join(cwd, '_content', 'config.yml')):
+        cwd = os.path.dirname(cwd)
+        if not cwd:
+            return None
+    return cwd
+