Workflow fixes towards blog #4

This commit is contained in:
frikky
2020-06-25 21:06:01 +02:00
parent 85835e02f5
commit 99ec5739e6
5 changed files with 90 additions and 189 deletions
+24 -7
View File
@@ -173,7 +173,16 @@ class AppBase:
if "split" in thistype:
return data.split()
if "len" in thistype or "length" in thistype:
return len(data)
tmp = ""
try:
tmp = json.loads(data)
except:
pass
if isinstance(tmp, list):
return str(len(tmp))
return str(len(data))
if "parse" in thistype:
splitvalues = []
default_error = """Error. Expected syntax: parse(["hello","test1"],0:1)"""
@@ -554,13 +563,21 @@ class AppBase:
if destinationvalue.lower() in sourcevalue.lower():
return True
elif check.lower() == "larger than":
if sourcevalue.isdigit() and destinationvalue.isdigit():
if int(sourcevalue) > int(destinationvalue):
return True
try:
if sourcevalue.isdigit() and destinationvalue.isdigit():
if int(sourcevalue) > int(destinationvalue):
return True
except AttributeError as e:
self.logger.error("Condition larger than failed with values %s and %s: %s" % (sourcevalue, destinationvalue, e))
return False
elif check.lower() == "smaller than":
if sourcevalue.isdigit() and destinationvalue.isdigit():
if int(sourcevalue) < int(destinationvalue):
return True
try:
if sourcevalue.isdigit() and destinationvalue.isdigit():
if int(sourcevalue) < int(destinationvalue):
return True
except AttributeError as e:
self.logger.error("Condition smaller than failed with values %s and %s: %s" % (sourcevalue, destinationvalue, e))
return False
else:
self.logger.info("Condition: can't handle %s yet. Setting to true" % check)