#416: Added Liquid formattinggit status

This commit is contained in:
frikky
2021-08-03 00:33:48 +02:00
parent a6a18acd3c
commit e8b7b2b444
5 changed files with 46 additions and 7 deletions
+3 -3
View File
@@ -6,11 +6,11 @@ RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-de
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
FROM base
COPY --from=builder /install /usr/local
COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
COPY __init__.py /app/walkoff_app_sdk/__init__.py
COPY app_base.py /app/walkoff_app_sdk/app_base.py
+38 -1
View File
@@ -10,6 +10,8 @@ import urllib.parse
import http.client
import urllib3
import hashlib
from liquid import Liquid
import liquid
class AppBase:
__version__ = None
@@ -1509,6 +1511,31 @@ class AppBase:
print("Error in decoder: %s" % e)
return returndata, is_loop
def parse_liquid(template):
#print("Inside liquid with glob: %s" % globals())
try:
#print(globals())
print("Running with \"%s\"" % template)
run = Liquid(template, {'mode': 'python'})
ret = run.render(**globals())
return ret
#try:
#run = Liquid(template)
#return ret
#except liquid.exceptions.LiquidSyntaxError as e:
# run = Liquid(template, {'mode': 'python'})
# ret = run.render(**globals())
# return ret
#except liquid.exceptions.LiquidRenderError as e:
# print("Render error: %s" % e)
except liquid.exceptions.LiquidRenderError as e:
print("Render error: %s" % e)
except liquid.exceptions.LiquidSyntaxError as e:
print("Syntax error: %s" % e)
return template
# Parses parameters sent to it and returns whether it did it successfully with the values found
def parse_params(action, fullexecution, parameter):
# Skip if it starts with $?
@@ -1518,7 +1545,8 @@ class AppBase:
# Matches with space in the first part, but not in subsequent parts.
# 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,})"
#match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})"
match = ".*?([$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})" # Removed space - no longer ok
# Regex to find all the things
if parameter["variant"] == "STATIC_VALUE":
@@ -1640,6 +1668,15 @@ class AppBase:
except json.decoder.JSONDecodeError as e:
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
# Just here in case it breaks
# Implemented 02.08.2021
print("Pre liquid: %s" % parameter["value"])
try:
parameter["value"] = parse_liquid(parameter["value"])
except:
pass
print("POST liquid: %s" % parameter["value"])
return "", parameter["value"], is_loop
def run_validation(sourcevalue, check, destinationvalue):
+1 -1
View File
@@ -3,7 +3,7 @@
### DEFAULT
NAME=shuffle-app_sdk
VERSION=0.9.05
VERSION=0.9.06
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
+1
View File
@@ -1,2 +1,3 @@
urllib3==1.25.9
requests==2.25.1
liquidpy==0.6.3