Remove escape characters from pipeline graphs
related with task #122
So far this is what I got to remove all these escapes
def get_graph(self):
response = self._client.pipeline_get_graph(self._name)
if response['code'] == '0':
import ast
import graphviz
graph = response['response']['value']
out = graph.replace('\\n', ' ') # Replace newlines with spaces
out = ast.literal_eval(out) # Decodes \012 to \n
out = out.replace('\\l', '').replace('\\', '') # Remove \l and \
out = " ".join(out.split()) # remove multiple spaces
dot = graphviz.Source(out)
That ended up removing too many escapes, this seemed to be a bit better.
def get_graph(self):
response = self._client.pipeline_get_graph(self._name)
dot = None
if response['code'] == 0:
import ast
import graphviz
import re
graph = response['response']['value']
out = graph.replace('\\n', ' ') # Replace newlines with spaces
out = ast.literal_eval(out) # Decodes \012 to \n
out = out.replace('\\l', '') # Remove random \l's ...
# Remove all \\ escapes except for \" and \%
out = re.sub(r"\\( |{|}|=|;|<|>|\[|\]|,|!|l|~|\(|\)|\*|\#)", r"\1", out)
out = " ".join(out.split()) # remove multiple spaces
dot = graphviz.Source(out)
return dot
Hi, may I ask if this fix is enabled on 0.14? I tried a lot of unescaping and unencoding on the graphviz output from 0.12.0 but no luck there.
Hi @guillebot
I was responsible of the v0.14. In this case, the only novelty was the introduction of non-parametric Element Actions. The team has this issue on the track.
Regards, Leon
Thank you very much @lleon95! Will keep an eye on it. As you can see the current output is, at least, very difficult to use.
regards