def __init__(self): # Find Project Root path.current = os.getcwd() path.root = recurse_up(path.current, 'Cakefile') if path.root: os.chdir(path.root) sys.path.insert(0, '') # Print project path puts(fore.yellow('(in %s)' % path.root)) else: raise CakeError('Cakefile not found') # Prepare environment self.env = {} self.tasks = {} # Read Cakefile with open('Cakefile') as f: exec(f.read(), self.env) # Load all tasks for name, task in self.env.items(): if getattr(task, '_task', False): self.tasks[name] = task
def find_project(): current = os.getcwd() return recurse_up(current, 'Cakefile')