comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:a212a3f2e3ee
1 import os
2 import os.path
3
4
5 class SiteNotFoundError(Exception):
6 def __init__(self, root=None):
7 if not root:
8 root = os.getcwd()
9 Exception.__init__(self,
10 "No PieCrust website in '%s' "
11 "('_content/config.yml' not found!)." % root)
12
13
14 def find_app_root(cwd=None):
15 if cwd is None:
16 cwd = os.getcwd()
17
18 while not os.path.isfile(os.path.join(cwd, '_content', 'config.yml')):
19 cwd = os.path.dirname(cwd)
20 if not cwd:
21 return None
22 return cwd
23