pombreda / pydot

Automatically exported from code.google.com/p/pydot
MIT License
0 stars 0 forks source link

: included as value for any attribute causes error #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Whenever a colon(:) occurs in the value field of any of the
attributes, pydot throws an error. Please someone fix this as soon as
possible.

It is very likely to have ":" in the value provided to the URL
attribute. In my case I tried to create a node with URL='http://
www.google.com' but unfortunately this does not work. If I remove the
colon i.e give URL='http//www.google.com', it works without any error
but that doesn't serve the purpose. So it needs to be handled.

Original issue reported on code.google.com by divya...@gmail.com on 24 Mar 2009 at 2:32

GoogleCodeExporter commented 9 years ago
Make sure the URL is in quotes in the dot file, e.g. 

node = pydot.Node(nodeid, label=name, shape="rect", style="filled", 
fillcolor="green", URL=('"http://%s:40000/job?guid=%s"' % (self.grid, 
self.resultcache[name])))

Note the extra quotes

Original comment by kevin.ma...@gmail.com on 31 Mar 2009 at 10:49

GoogleCodeExporter commented 9 years ago
This is really an unsatisfactory solution. If the variable 'name' above 
contained a
colon, the name would be truncated at that character:

>>> myname = "kept:lost"
>>> n = pydot.Node(myname)
>>> n.get_name()
'kept'

I shouldn't need to perform a deep inspection of my strings to weed out colons. 
That
is, I shouldn't have to perform a colonoscopy.

Do we have any alternatives? Is there any way to change the separator character?

Original comment by oli...@gmail.com on 6 May 2009 at 11:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've been able to add strings with colons, wrapping the string with quotes, 
like 
this:

myString = "\"" + "http://www.google.com" + "\""
n = pydot.Node(myString)

you have to put the quotes before you create the node, otherwise it doesn't 
work.
It's kinda weird, but it works.

Original comment by vpa...@gmail.com on 25 Nov 2009 at 4:39

GoogleCodeExporter commented 9 years ago
Putting aside URLs for a moment, imagine that you have a huge collection of 
assorted
strings that will be used as Node labels. If any one of them _might_ contain a 
colon,
you need to wrap _all_ of my labels in escaped quotes. Not only does this 
increase
the length of every label by two characters (which can matter with large 
graphs), but
you need to add and strip those quotes whenever you move from pydot back to the
original domain of strings.

I appreciate that there is a workaround, but that workaround is (1) 
undocumented, (2)
adds overhead to every node creation and label use, and (3) increases the 
length of
the labels. This is a bug that deserves a proper solution.

Original comment by oli...@gmail.com on 25 Nov 2009 at 5:56

GoogleCodeExporter commented 9 years ago
hello
I thing this problem is somehow related :

n1 = '"%s (= %s)"' % ("aaa-vvv", "1:2.1-3")
n2 = '"%s (= %s)"' % ("aaa-vvv", "1:2.1-3")
In [25]: pydot.Edge(pydot.Node(n1),pydot.Node(n2)).to_string()
Out[25]: '""aaa-vvv (= 1":"2.1-3)"" -- ""aaa-vvv (= 1":"2.1-3)"";'

while it should be :
"aaa-vvv (= 1:2.1-3)" -> "aaa-vvv (= 1:2.1-3)"

the node itself is ok :

In [26]: pydot.Node(n1).to_string()
Out[26]: '"aaa-vvv (= 1:2.1-3)";'

is there a workaround for this ?

Original comment by dr.mu...@gmail.com on 13 Oct 2010 at 1:29

GoogleCodeExporter commented 9 years ago
me again.
I think this specific issue can be resolved with simple patch in parse_node_ref 
:

844c844
<         if node_str.startswith('"') and node_str.endswith('"'):
---
>         if node_str.startswith('"') and node_str.endswith('"') and 
node_str.count('"') % 2 != 0:

does this break anything else ?

Original comment by dr.mu...@gmail.com on 13 Oct 2010 at 2:29

GoogleCodeExporter commented 9 years ago
Responding to the original issue: The problem with the colon in Node names is 
that GraphViz will use them to specify a port where to attach edges, it's a 
Graphviz artifact. The way pydot supports them is to allow them in names, if 
you wish to simply have colon characters in the name simply add quotes to the 
string.

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 11:26

GoogleCodeExporter commented 9 years ago
Issue 38 has been merged into this issue.

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 11:29