Substitute variables in lists #25

This commit is contained in:
Olivier 'reivilibre' 2021-02-28 20:08:10 +00:00
parent bc07cdc5eb
commit c0adcd2c73

View File

@ -182,6 +182,15 @@ class Variables:
key, expr = incoming.popitem()
if isinstance(expr, str):
value = self._eval_with_incoming(expr, incoming)
# elif isinstance(expr, list): not what I thought
# # TODO this is still not 100% coverage of variables but good enough
# # for now?
# value = []
# for item in expr:
# if isinstance(item, str):
# value.append(self._eval_with_incoming(item, incoming))
# else:
# value.append(item)
else:
value = expr
self.set_dotted(key, value)
@ -198,6 +207,12 @@ class Variables:
self.substitute_inplace_in_dict(v)
elif isinstance(v, str):
dictionary[k] = self.eval(v)
elif isinstance(v, list):
for idx, item in enumerate(v):
if isinstance(item, str):
v[idx] = self.eval(item)
elif isinstance(item, dict):
self.substitute_inplace_in_dict(item)
def substitute_in_dict_copy(self, dictionary: Dict[str, Any]):
new_dict = deepcopy(dictionary)