view piecrust/pathutil.py @ 3:f485ba500df3

Gigantic change to basically make PieCrust 2 vaguely functional. - Serving works, with debug window. - Baking works, multi-threading, with dependency handling. - Various things not implemented yet.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 10 Aug 2014 23:43:16 -0700
parents aaa8fb7c8918
children 485682a6de50
line wrap: on
line source

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 or cwd == '/':
            return None
    return cwd