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): ...@@ -12,20 +12,21 @@ def populate(context, args, key, table, replace=True):
args. args.
""" """
conf = celery.current_app.scheduler.config conf = celery.current_app.scheduler.config
for item in (context, args): def do_populate(item):
if replace: for value in item.values():
if key in item and type(item[key]) is str: if type(value) is dict:
item[key] = conf[table].get(item[key], item[key]) do_populate(value)
elif key in item and type(item[key]) is list: if replace and key in item and type(item[key]) is str:
item[key] = { item[key] = conf[table].get(item[key], item[key])
entry: conf[table].get(entry, entry) elif replace and key in item and type(item[key]) is list:
for entry in context[key] item[key] = {entry: conf[table].get(entry, entry)
} for entry in context[key]}
else: elif key in item and type(item[key]) is str:
if key in item and type(item[key]) is str: item.update(conf[table][item[key]])
item.update(conf[table][item[key]]) del item[key]
del item[key]
for item in (context, args):
do_populate(item)
return (context, args) 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