def resolveItem(action, item): resolved = {} if hasattr(action, "resolve"): for label, keys in action.resolve["get"].items(): target = item for key in keys: target = target[key] resolved[label] = target if "construct" in action.resolve: for label2, piece in action.resolve["construct"].items(): constructed = "" for item in piece: if isinstance(item, dict): for key, value in item.items(): item = resolved[value] constructed += str(item) resolved[label2] = constructed if "transform" in action.resolve: for source, mutation in action.resolve["transform"].items(): for key, value in mutation.items(): if resolved[source] == key: resolved[source] = value if "deconstruct" in action.resolve: for source, mutation in action.resolve["deconstruct"].items(): deconstructed = str(resolved[source]) for item in mutation: deconstructed = deconstructed.replace(str(item), "") resolved[source] = deconstructed return resolved