Skip to content

Commit

Permalink
Added support for executing Python from defaults file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrimko committed Dec 14, 2017
1 parent 824fef5 commit 5b97049
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/utilconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def ctor_file(loader, node):
value = loader.construct_scalar(node)
return FileReader(value)

def ctor_py(loader, node):
seq = loader.construct_sequence(node)
cmd = seq.pop(0).format(*seq)
return eval(cmd)

def ctor_yaml(loader, node):
value = loader.construct_scalar(node)
return IncLoader(value)
Expand Down Expand Up @@ -146,6 +151,7 @@ def get_tmpldict(args):
yaml.add_constructor(u'!yaml', ctor_yaml)
yaml.add_constructor(u'!opt', ctor_opt)
yaml.add_constructor(u'!ask', ctor_ask)
yaml.add_constructor(u'!py', ctor_py)

# Prepare template dictionary.
tmpldict = {}
Expand Down

0 comments on commit 5b97049

Please sign in to comment.