pombreda / pydot

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

get_subgraphs() and get_subgraph() broken in 1.0.2 #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the following (or similar) interactive Python session:

>>> import pydot
>>> g = pydot.Graph()
>>> s = pydot.Subgraph("foo")
>>> g.get_subgraphs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.6/pydot.py", line 1345, in
get_subgraphs
    return get_subgraph_list()
NameError: global name 'get_subgraph_list' is not defined
>>> g.get_subgraph_list()
[]
>>> sgs = g.add_subgraph(s)
>>> g.get_subgraphs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.6/pydot.py", line 1345, in
get_subgraphs
    return get_subgraph_list()
NameError: global name 'get_subgraph_list' is not defined
>>> g.get_subgraph_list()
[<pydot.Subgraph object at 0xa279d2c>]
>>> g.get_subgraph("foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.6/pydot.py", line 1330, in get_subgraph
    if self.obj_dict['subgraphs'].has_key( sgraph.get_name() ):
NameError: global name 'sgraph' is not defined

What is the expected output? What do you see instead?

  There are global name problems in the implementations of the
Graph.get_subgraphs() and Graph.get_subgraph(<name>) functions. This may
just be a case of having forgotten to include the "self" argument, which
has skipped by testing if the tests don't use subgraphs.

What version of the product are you using? On what operating system?

  I'm using the system package of pydot on Ubuntu 9.04 (Jaunty)

  >>> pydot.__version__
  '1.0.2'

Original issue reported on code.google.com by purity0...@gmail.com on 16 May 2009 at 4:10

GoogleCodeExporter commented 9 years ago
I have seen it too.
The fix for pydot.py would be:

@@ -1325,11 +1325,11 @@
         None is returned otherwise.
         """

-        match = None
+        match = list()

-        if self.obj_dict['subgraphs'].has_key( sgraph.get_name() ):
+        if self.obj_dict['subgraphs'].has_key( name ):

-            sgraphs_obj_dict = self.obj_dict['subgraphs'].get( 
sgraph.get_name() )
+            sgraphs_obj_dict = self.obj_dict['subgraphs'].get( name )

             for obj_dict_list in sgraphs_obj_dict:
                 match = [ Subgraph( obj_dict = obj_d ) for obj_d in obj_dict_list ]

Consider contributing to the project to solve it directly in the archive.

Original comment by kzhuli...@gmail.com on 13 Jul 2010 at 11:15

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 5:45

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

Original comment by ero.carr...@gmail.com on 31 Oct 2010 at 12:19

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 31 Oct 2010 at 12:22