Made app_sdk loop parser more stable. Still missing recursion.
This commit is contained in:
@@ -386,18 +386,20 @@ class AppBase:
|
|||||||
except json.decoder.JSONDecodeError as e:
|
except json.decoder.JSONDecodeError as e:
|
||||||
return baseresult
|
return baseresult
|
||||||
|
|
||||||
|
# This whole thing should be recursive.
|
||||||
try:
|
try:
|
||||||
cnt = 0
|
cnt = 0
|
||||||
for value in parsersplit[1:]:
|
for value in parsersplit[1:]:
|
||||||
cnt += 1
|
cnt += 1
|
||||||
|
|
||||||
|
print("VALUE: %s" % value)
|
||||||
if value == "#":
|
if value == "#":
|
||||||
# FIXME - not recursive - should go deeper if there are more #
|
# FIXME - not recursive - should go deeper if there are more #
|
||||||
print("HANDLE RECURSIVE LOOP OF %s" % basejson)
|
print("HANDLE RECURSIVE LOOP OF %s" % basejson)
|
||||||
returnlist = []
|
returnlist = []
|
||||||
try:
|
try:
|
||||||
for innervalue in basejson:
|
for innervalue in basejson:
|
||||||
print("Value: %s" % value[parsersplit[cnt+1]])
|
print("Value: %s" % innervalue[parsersplit[cnt+1]])
|
||||||
returnlist.append(innervalue[parsersplit[cnt+1]])
|
returnlist.append(innervalue[parsersplit[cnt+1]])
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
print("Indexerror inner: %s" % e)
|
print("Indexerror inner: %s" % e)
|
||||||
@@ -410,8 +412,7 @@ class AppBase:
|
|||||||
print("INDEXVAL: ", indexvalue)
|
print("INDEXVAL: ", indexvalue)
|
||||||
return indexvalue
|
return indexvalue
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
print("Inner TypeError: %s" % e)
|
print("TypeError inner: %s" % e)
|
||||||
return basejson
|
|
||||||
|
|
||||||
# Example format: ${[]}$
|
# Example format: ${[]}$
|
||||||
parseditem = "${%s%s}$" % (parsersplit[cnt+1], json.dumps(returnlist))
|
parseditem = "${%s%s}$" % (parsersplit[cnt+1], json.dumps(returnlist))
|
||||||
@@ -419,6 +420,10 @@ class AppBase:
|
|||||||
return parseditem
|
return parseditem
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
print("BEFORE NORMAL VALUE: ", basejson, value)
|
||||||
|
if len(value) == 0:
|
||||||
|
return basejson
|
||||||
|
|
||||||
if isinstance(basejson[value], str):
|
if isinstance(basejson[value], str):
|
||||||
print(f"LOADING STRING '%s' AS JSON" % basejson[value])
|
print(f"LOADING STRING '%s' AS JSON" % basejson[value])
|
||||||
try:
|
try:
|
||||||
@@ -436,13 +441,14 @@ class AppBase:
|
|||||||
return basejson
|
return basejson
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_params(action, fullexecution, parameter):
|
def parse_params(action, fullexecution, parameter):
|
||||||
# Skip if it starts with $?
|
# Skip if it starts with $?
|
||||||
jsonparsevalue = "$."
|
jsonparsevalue = "$."
|
||||||
|
|
||||||
# Matches with space in the first part, but not in subsequent parts.
|
# Matches with space in the first part, but not in subsequent parts.
|
||||||
# JSON / yaml etc shouldn't have spaces in their fields anyway.
|
# JSON / yaml etc shouldn't have spaces in their fields anyway.
|
||||||
match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9_-]+\.?){0,})"
|
match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})"
|
||||||
|
|
||||||
# Regex to find all the things
|
# Regex to find all the things
|
||||||
if parameter["variant"] == "STATIC_VALUE":
|
if parameter["variant"] == "STATIC_VALUE":
|
||||||
|
|||||||
+67
-19
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user