Git Product home page Git Product logo

pydot's Introduction

pydot - Python interface to Graphviz's Dot language
Ero Carrera (c) 2004-2007
[email protected]

This code is distributed under the MIT license.

Requirements:
-------------

pyparsing: pydot requires the pyparsing module in order to be
	able to load DOT files.

GraphViz:  is needed in order to render the graphs into any of
	the plethora of output formats supported.

Installation:
-------------

Should suffice with doing:

 python setup.py install

Needless to say, no installation is needed just to use the module. A mere:

 import pydot

should do it, provided that the directory containing the modules is on Python
module search path.

pydot's People

Contributors

chebee7i avatar erocarrera avatar graingert avatar gustavla avatar nlhepler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydot's Issues

Package is not available on pypi

I want to publish a package on pypi that depends on pydot.

As you're aware, the pypi package is unmaintained an out-of-date.

I briefly had my own fork and contacted the maintainer. He seemed willing to pass on ownership of the palckage, but the conversation never went beyond that.

IMO uploading the package under a different name (even pydot2) would be a good way forward.

python3 compatibility

The description of the repository implies compatibility with python3, yet there is a syntax error in setup.py:

  File "setup.py", line 5
    except ImportError, excp:
                      ^
SyntaxError: invalid syntax

Bytes/String node name interaction with NX

I'm trying to use this bootleg (:P, fix #12 ASAP!) package with NX 1.9.1 and Python 3 on Windows with GV 2.38 and when NX tries to read back in the position data, it coughs because of this line (errors a couple lines down when it tries to get the 0th element of an empty list) because it seems to think the nodes are named with bytes (py2 string), rather than unicode (py3 string). Without the encode it works (on Python 3 at least...can't easily switch to 2 on Windows)...

Aaanyways, I'm not sure if this should be fixed here or in NX. It's probably not been noticed/reported there because the "official" (#12...) pydot only supports Python 2.

Here's a monkeypatch that seems to work wherein I strip out the .encode()

import pydot
import networkx as nx
from networkx.drawing.nx_pydot import to_pydot, make_str
def pydot_layout(G,prog='neato',root=None, **kwds):
    """Create node positions using Pydot and Graphviz.
    Returns a dictionary of positions keyed by node.
    Examples
    --------
    >>> G=nx.complete_graph(4)
    >>> pos=nx.pydot_layout(G)
    >>> pos=nx.pydot_layout(G,prog='dot')
    """
    #pydot = load_pydot() #### EDIT (but not really important for this)

    P=to_pydot(G)
    if root is not None :
        P.set("root",make_str(root))

    D=P.create_dot(prog=prog)

    if D=="":  # no data returned
        print("Graphviz layout with %s failed"%(prog))
        print()
        print("To debug what happened try:")
        print("P=pydot_from_networkx(G)")
        print("P.write_dot(\"file.dot\")")
        print("And then run %s on file.dot"%(prog))
        #return

    Q=pydot.graph_from_dot_data(D)

    node_pos={}
    for n in G.nodes():
        ####################################################
        pydot_node = pydot.Node(make_str(n)).get_name()#.encode('utf-8') # no encode = fix
        ####################################################
        node=Q.get_node(pydot_node)

        if isinstance(node,list):
            node=node[0]
        pos=node.get_pos()[1:-1] # strip leading and trailing double quotes
        if pos != None:
            xx,yy=pos.split(",")
            node_pos[n]=(float(xx),float(yy))
    return node_pos
nx.drawing.nx_pydot.pydot_layout = pydot_layout

setup.py and source tarballs

Thank you very much for this initiative.
Is it possible to address a couple of remaining issues?

  1. in the setup, this line is rather unorthodox:
    data_files = [('.', ['LICENSE', 'README'])] )

it might be better to put everything into a pydot subdirectory to coexist with other python modules.
2. for pkgsrc, we typically use the gzipped tarball for the source download, currently http://pydot.googlecode.com/files/pydot-1.0.28.tar.gz as indicated on https://pypi.python.org/pypi/pydot. Do you plan on updating this or providing an alternative?

unittests errors

Hello, I got these errors (they are for python3.5, but they are the same on 2.7 and 3.4):

FAIL: test_graph_with_shapefiles (__main__.TestGraphAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/pydot_unittest.py", line 166, in test_graph_with_shapefiles
    self.assertEqual(hexdigest, hexdigest_original)
AssertionError: '570025288f29983b8793c9897fde68b4567cdcb54d2580a717d908b7c25ec83d' != '5c1ad2e74d62173ffc0f66efbf9e0ee4af2dbbd1383824984bf9a343947bac59'
- 570025288f29983b8793c9897fde68b4567cdcb54d2580a717d908b7c25ec83d
+ 5c1ad2e74d62173ffc0f66efbf9e0ee4af2dbbd1383824984bf9a343947bac59


======================================================================
FAIL: test_graphviz_regression_tests (__main__.TestGraphAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/pydot_unittest.py", line 225, in test_graphviz_regression_tests
    self._render_and_compare_dot_files(REGRESSION_TESTS_DIR)
  File "test/pydot_unittest.py", line 252, in _render_and_compare_dot_files
    self.assertEqual(parsed_data_hexdigest, original_data_hexdigest)
AssertionError: '039cccb1fb1dd6e4a0381ebf34cc9712a3137179f466b027b847a382b46f88ac' != 'bb2aa7104b9a5e52e70331a1eb9ad028feafa9894e22b0e0195ed0194e047e58'
- 039cccb1fb1dd6e4a0381ebf34cc9712a3137179f466b027b847a382b46f88ac
+ bb2aa7104b9a5e52e70331a1eb9ad028feafa9894e22b0e0195ed0194e047e58

Writing to an open file

It'd be useful if the write() method on the Dot class could take an open file, rather than just a path; this would allow idiomatic stuff like giving it a string buffer, the sys.stdout object, a network socket, etc.

Happy to implement this in a fork and put in a pull request if there's no objection.

Unknown distribution option: 'install_requires'

$ python3 setup.py install
/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)

Shouldn't pyparsing be in the dependencies dict?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.