gstd-1.x icon indicating copy to clipboard operation
gstd-1.x copied to clipboard

Remove escape characters from pipeline graphs

Open carlos-aguero opened this issue 5 years ago • 5 comments

related with task #122

carlos-aguero avatar May 04 '20 16:05 carlos-aguero

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)

jcormier avatar Nov 10 '21 17:11 jcormier

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

jcormier avatar Nov 17 '21 19:11 jcormier

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.

guillebot avatar Mar 10 '22 19:03 guillebot

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

lleon95 avatar Mar 10 '22 19:03 lleon95

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

guillebot avatar Mar 10 '22 19:03 guillebot