Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kokki/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def main():
globs["__file__"] = os.path.abspath(fname)
with open(fname, "rb") as fp:
source = fp.read()
exec compile(source, fname, 'exec') in globs
exec compile(source, os.path.abspath(fname), 'exec') in globs
del globs['__file__']

kit = Kitchen()
Expand All @@ -74,15 +74,15 @@ def main():
sys.exit(1)
for r in roles:
r(kit)

for over in options.overrides:
name, value = over.split('=', 1)
try:
value = int(value)
except ValueError:
pass
kit.update_config({name: value})

if options.dump:
if ':' in options.dump:
fmt, filename = options.dump.split(':', 1)
Expand Down
14 changes: 7 additions & 7 deletions kokki/kitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def library(self):
path = os.path.join(libpath, f)
with open(path, "rb") as fp:
source = fp.read()
exec compile(source, libpath, "exec") in globs
exec compile(source, path, "exec") in globs

self._library = AttributeDictionary(globs)
return self._library

Expand All @@ -58,7 +58,7 @@ def get_recipe(self, name):
raise Fail("Recipe %s in cookbook %s not found" % (name, self.name))

with open(path, "rb") as fp:
return fp.read()
return fp.read(), path

def __getattr__(self, name):
return self.library[name]
Expand All @@ -76,7 +76,7 @@ def __unicode__(self):
class Kitchen(Environment):
def __init__(self):
super(Kitchen, self).__init__()
self.included_recipes_order = []
self.included_recipes_order = []
self.included_recipes = {}
self.sourced_recipes = set()
self.cookbooks = AttributeDictionary()
Expand Down Expand Up @@ -121,7 +121,7 @@ def include_recipe(self, *args):
cookbook, recipe = name.split('.')
except ValueError:
cookbook, recipe = name, "default"

try:
cb = self.cookbooks[cookbook]
except KeyError:
Expand All @@ -142,10 +142,10 @@ def source_recipe(self, cookbook, recipe):
self.sourced_recipes.add(name)
cookbook.loader(self)

rc = cookbook.get_recipe(recipe)
rc, path = cookbook.get_recipe(recipe)
globs = {'env': self}
with self:
exec compile(rc, name, 'exec') in globs
exec compile(rc, path, 'exec') in globs

def prerun(self):
for name in self.included_recipes_order:
Expand Down