Added resolveItem2. Currently not implemented. Updated targeting to be conditional and not mandatory
This commit is contained in:
@@ -5,7 +5,8 @@ def resolveItem(action, item):
|
||||
target = item
|
||||
|
||||
for key in keys:
|
||||
target = target[key]
|
||||
target = target.get(key)
|
||||
#target = target[key]
|
||||
|
||||
resolved[label] = target
|
||||
if "construct" in action.resolve:
|
||||
@@ -37,3 +38,46 @@ def resolveItem(action, item):
|
||||
resolved[source] = deconstructed
|
||||
|
||||
return resolved
|
||||
|
||||
|
||||
def resolveItem2(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
|
||||
|
||||
for mutation in action.resolve.get("mutate", []):
|
||||
if "construct" in mutation:
|
||||
for label2, piece in mutation["construct"].items():
|
||||
constructed = ""
|
||||
|
||||
for part in piece:
|
||||
if isinstance(part, dict):
|
||||
for key, value in part.items():
|
||||
part = resolved[value]
|
||||
|
||||
constructed += str(part)
|
||||
|
||||
resolved[label2] = constructed
|
||||
elif "transform" in mutation:
|
||||
for source, transformation in mutation["transform"].items():
|
||||
for key, value in transformation.items():
|
||||
if resolved[source] == key:
|
||||
resolved[source] = value
|
||||
|
||||
elif "deconstruct" in mutation:
|
||||
for source, change in mutation["deconstruct"].items():
|
||||
deconstructed = str(resolved[source])
|
||||
|
||||
for removal in change:
|
||||
|
||||
deconstructed = deconstructed.replace(str(removal), "")
|
||||
|
||||
resolved[source] = deconstructed
|
||||
|
||||
return resolved
|
||||
Reference in New Issue
Block a user