Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with colon in name of PORT #54

Closed
CheshireB opened this issue Jul 9, 2018 · 2 comments
Closed

Bug with colon in name of PORT #54

CheshireB opened this issue Jul 9, 2018 · 2 comments

Comments

@CheshireB
Copy link

CheshireB commented Jul 9, 2018

Example

from graphviz import Digraph

dot = Digraph('structs', node_attr={'shape': 'plaintext'})

dot.node('struct1',
            '''< 
                <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
                    <TR>
                        <TD PORT="1" ROWSPAN="2">1</TD>
                        <TD PORT="1:2" ROWSPAN="1">1:2</TD>
                    </TR>
                    <TR>
                        <TD PORT="1:3" ROWSPAN="1">1:3</TD>
                    </TR>
                </TABLE>
            >'''
)

dot.node('struct2',
            '''< 
                <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
                    <TR>
                        <TD PORT="2" ROWSPAN="2">2</TD>
                        <TD PORT="2:2" ROWSPAN="1">2:2</TD>
                    </TR>
                    <TR>
                        <TD PORT="2:3" ROWSPAN="1">2:3</TD>
                    </TR>
                </TABLE>
            >'''
)

dot.edges([('struct1:1:2', 'struct2:2:2')])



dot.view('test-output/round-table.gv')

Result

Warning: node struct1, port 1, unrecognized compass point '2' - ignored
Warning: node struct2, port 2, unrecognized compass point '2' - ignored

** (exo-open:15248): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-UFsPtsUMtY: Connection refused

dot.source

digraph structs {
	node [shape=plaintext]
	struct1 [label=< 
                <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
                    <TR>
                        <TD PORT="1" ROWSPAN="2">1</TD>
                        <TD PORT="1:2" ROWSPAN="1">1:2</TD>
                    </TR>
                    <TR>
                        <TD PORT="1:3" ROWSPAN="1">1:3</TD>
                    </TR>
                </TABLE>
            >]
	struct2 [label=< 
                <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
                    <TR>
                        <TD PORT="2" ROWSPAN="2">2</TD>
                        <TD PORT="2:2" ROWSPAN="1">2:2</TD>
                    </TR>
                    <TR>
                        <TD PORT="2:3" ROWSPAN="1">2:3</TD>
                    </TR>
                </TABLE>
            >]
}

Image
screenshot_2018-07-09_15-26-43

Info
graphviz: 0.8.3
python: 3.6

@xflr6
Copy link
Owner

xflr6 commented Jul 10, 2018

Thanks, loosely related to #53 (special status of colon in the DOT language). From the language specification, I think that you would need to quote a port name that should contain a literal :, but it does not seem to work with the following (raw DOT, using &quot; to escape the quoting of 1:2 in the PORT attribute):

In [1]: import graphviz
   ...: 
   ...: s = graphviz.Source('''
   ...: digraph structs {
   ...:   node [shape=plaintext]
   ...:   struct1 [label=< 
   ...:     <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
   ...:       <TR>
   ...:         <TD PORT="1" ROWSPAN="2">1</TD>
   ...:         <TD PORT="&quot;1:2&quot;" ROWSPAN="1">1:2</TD>
   ...:       </TR>
   ...:       <TR>
   ...:         <TD PORT="1:3" ROWSPAN="1">1:3</TD>
   ...:       </TR>
   ...:     </TABLE>>]
   ...:   struct2 [label=< 
   ...:     <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
   ...:       <TR>
   ...:         <TD PORT="2" ROWSPAN="2">2</TD>
   ...:         <TD PORT="&quot;2:2&quot;" ROWSPAN="1">2:2</TD>
   ...:       </TR>
   ...:       <TR>
   ...:         <TD PORT="2:3" ROWSPAN="1">2:3</TD>
   ...:       </TR>
   ...:     </TABLE>>]
   ...:   struct1:"1:2" -> struct2:"2:2"
   ...: }''')

Do you know a working DOT source works for this (literal colon in port)? Might be an upstream issue. I guess one can currently work around by avoiding : in port names.

@xflr6
Copy link
Owner

xflr6 commented Jul 15, 2018

Looks like Graphviz (the upstream package) does not support colons in port names properly. I could not find a working DOT source for using a port name with a colon. E.g. the following does not work as intended:

import graphviz

graphviz.Source(r'''
digraph g {
  spam[label="left|middle|<f2:1> right", shape=record]
  spam:"f2:1" -> "eggs:eggs":s
}''')
Warning: node spam, port f2 unrecognized
Out[1]: 

spam

Also does not start the edge from the right port when using this instead:
spam -> "eggs:eggs":s [taillabel="f2:1"].

For issues with colons in edge statements specific to this package see #53.
Closing this for now (AFAIU, you could report this upstream to https://gitlab.com/graphviz/graphviz/issues).

@xflr6 xflr6 closed this as completed Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants