Commit c5b7bc8f authored by kaiyou's avatar kaiyou

Be recursive on dicts when populating arguments

parent 4f2fb2b6
......@@ -12,20 +12,21 @@ def populate(context, args, key, table, replace=True):
args.
"""
conf = celery.current_app.scheduler.config
for item in (context, args):
if replace:
if key in item and type(item[key]) is str:
def do_populate(item):
for value in item.values():
if type(value) is dict:
do_populate(value)
if replace and key in item and type(item[key]) is str:
item[key] = conf[table].get(item[key], item[key])
elif key in item and type(item[key]) is list:
item[key] = {
entry: conf[table].get(entry, entry)
for entry in context[key]
}
else:
if key in item and type(item[key]) is str:
elif replace and key in item and type(item[key]) is list:
item[key] = {entry: conf[table].get(entry, entry)
for entry in context[key]}
elif key in item and type(item[key]) is str:
item.update(conf[table][item[key]])
del item[key]
for item in (context, args):
do_populate(item)
return (context, args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment