graphviz-0.5.2/0000755000000000000000000000000013026663155012055 5ustar rootrootgraphviz-0.5.2/CHANGES0000666000000000000000000000747613020607262013061 0ustar rootrootChangelog ========= Version 0.5.2 ------------- Add ENGINES and FORMATS to the documented public API. Version 0.5.1 ------------- Fixed PY3 compatibility. Version 0.5 ----------- Add low-level functions render(), pipe(), and view() for directly working with existing files and strings. Support all render()-arguments in the view()-short-cut-method. Version 0.4.10 -------------- Added patchwork engine. Version 0.4.9 ------------- Add support for 'strict' graphs and digraphs. Hide render/pipe subrocess console window on Windows when invoked from non-console process (e.g. from IDLE). Improve documentation markup/wording. Make TestNoent more robust. Version 0.4.8 ------------- Make _repr_svg_ available on Source (pull request RafalSkolasinski). Version 0.4.7 ------------- Fixed view()-method on Linux under Python 3 (pull request Antony Lee). Version 0.4.6 ------------- Fixed view()-method on Linux and Darwin (pull request Eric L. Frederich). Version 0.4.5 ------------- Added example for HTML-like labels (structs.py). Added Source class for rendering verbatim DOT source code. Added Python 2.6 support (pull request Jim Crist). Version 0.4.4 ------------- Added the pipe()-method directly returning the stdout of the rendering. Added _repr_svg_ for inline rendering in IPython notebooks. Version 0.4.3 ------------- Added examples generating some of the graphs from the Graphviz Gallery. Added sphinx-based API documentation. Version 0.4.2 ------------- Added support for HTML-like labels. Version 0.4.1 ------------- Added support for less common output formats. Removed dropped formats (dia, pcl). Added osage layout engine. Documented format and engine options in the README. The view() convenience method now returns the result file name (like render()). Version 0.4 ----------- Added attr() method for inline switching of node/edge attributes. Added subgraph() method (obsoletes separate Subgraph class). Add cleanup option to render(). Replaced dry option on render() with separate save() method. Removed undocumented append() and extend() methods (if needed, the body attribute can be edited directly). Version 0.3.5 ------------- Skip empty comment when creating DOT source. Document graph_attr, node_attr, and edge_attr in the README. More informative exception when Graphviz excutables cannot be called. Version 0.3.4 ------------- Fixed missing identifier quoting for DOT keywords (thanks to Paulo Urio). Version 0.3.3 ------------- Made format and engine case-insensitive. Version 0.3.2 ------------- Indent graph_attr, node_attr, and edge_attr lines, adapt nodes and edges. Version 0.3.1 ------------- Fixed view() failing on paths with forward slashes on Windows. Version 0.3 ----------- Added Python 3.3+ support. Made attributes order stable (sorting plain dicts). Fixed edgeop in undirected graphs. Version 0.2.2 ------------- Support pdf opening on Linux. Fixed rendering filenames w/spaces. Version 0.2.1 ------------- Fixed rendering on Mac OS X. Version 0.2 ----------- Added format selection, use PDF as default. Added engines selection, use dot as default. Added source encoding, use UTF-8 as default. Changed constructor arguments order, removed compile and save method, reimplemented compilation in render method, make interface more similar to gv.3python (backwards incompatible change). Double-quote-sign escaping, attribute list quoting. mkdirs now correctly supports current directory filenames. Version 0.1.1 ------------- Removed automatic '-' to '−' replacement from labels. Fixed documentation typos. Version 0.1 ----------- First public release. graphviz-0.5.2/LICENSE0000666000000000000000000000212313020607126013052 0ustar rootrootThe MIT License (MIT) Copyright (c) 2013-2016 Sebastian Bank Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. graphviz-0.5.2/MANIFEST.in0000666000000000000000000000032013020607130013573 0ustar rootrootinclude README.rst LICENSE CHANGES include requirements.txt include run-tests.py recursive-include docs *.rst *.txt *.py *.png *.svg recursive-include examples *.py *.ipynb recursive-include tests *.py graphviz-0.5.2/PKG-INFO0000666000000000000000000001452113020607452013151 0ustar rootrootMetadata-Version: 1.1 Name: graphviz Version: 0.5.2 Summary: Simple Python interface for Graphviz Home-page: http://github.com/xflr6/graphviz Author: Sebastian Bank Author-email: sebastian.bank@uni-leipzig.de License: MIT Description: Graphviz ======== |PyPI version| |License| |Supported Python| |Format| |Downloads| This package facilitates the creation and rendering of graph descriptions in the DOT_ language of the Graphviz_ graph drawing software (repo_) from Python. Create a graph object, assemble the graph by adding nodes and edges, and retrieve its DOT source code string. Save the source code to a file and render it with the Graphviz installation of your system. Use the ``view`` option/method to directly inspect the resulting (PDF, PNG, SVG, etc.) file with its default application. Graphs can also be rendered and displayed within `Jupyter notebooks`_ (a.k.a. `IPython notebooks`_, example_). Links ----- - GitHub: http://github.com/xflr6/graphviz - PyPI: http://pypi.python.org/pypi/graphviz - Documentation: http://graphviz.readthedocs.io - Changelog: http://graphviz.readthedocs.io/en/latest/changelog.html - Issue Tracker: http://github.com/xflr6/graphviz/issues - Download: http://pypi.python.org/pypi/graphviz#downloads Installation ------------ This package runs under Python 2.6, 2.7, and 3.3+, use pip_ to install: .. code:: bash $ pip install graphviz To render the generated DOT source code, you also need to install Graphviz (`download page`_). Make sure that the directory containing the ``dot`` executable is on your systems' path. Quickstart ---------- Create a graph object: .. code:: python >>> from graphviz import Digraph >>> dot = Digraph(comment='The Round Table') >>> dot #doctest: +ELLIPSIS Add nodes and edges: .. code:: python >>> dot.node('A', 'King Arthur') >>> dot.node('B', 'Sir Bedevere the Wise') >>> dot.node('L', 'Sir Lancelot the Brave') >>> dot.edges(['AB', 'AL']) >>> dot.edge('B', 'L', constraint='false') Check the generated source code: .. code:: python >>> print(dot.source) # doctest: +NORMALIZE_WHITESPACE // The Round Table digraph { A [label="King Arthur"] B [label="Sir Bedevere the Wise"] L [label="Sir Lancelot the Brave"] A -> B A -> L B -> L [constraint=false] } Save and render the source code, optionally view the result: .. code:: python >>> dot.render('test-output/round-table.gv', view=True) 'test-output/round-table.gv.pdf' .. image:: https://raw.github.com/xflr6/graphviz/master/docs/round-table.png :align: center See also -------- - pygraphviz_ |--| full-blown interface wrapping the Graphviz C library with SWIG - graphviz-python_ |--| official Python bindings (documentation_) - pydot_ |--| stable pure-Python approach, requires pyparsing License ------- This package is distributed under the `MIT license`_. .. _pip: http://pip.readthedocs.io .. _Graphviz: http://www.graphviz.org .. _repo: http://github.com/ellson/graphviz/ .. _download page: http://www.graphviz.org/Download.php .. _DOT: http://www.graphviz.org/doc/info/lang.html .. _Jupyter notebooks: http://jupyter.org .. _IPython notebooks: http://ipython.org/notebook.html .. _example: http://nbviewer.jupyter.org/github/xflr6/graphviz/blob/master/examples/notebook.ipynb .. _pygraphviz: http://pypi.python.org/pypi/pygraphviz .. _graphviz-python: http://pypi.python.org/pypi/graphviz-python .. _documentation: http://www.graphviz.org/pdf/gv.3python.pdf .. _pydot: http://pypi.python.org/pypi/pydot .. _MIT license: http://opensource.org/licenses/MIT .. |--| unicode:: U+2013 .. |PyPI version| image:: https://img.shields.io/pypi/v/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Latest PyPI Version .. |License| image:: https://img.shields.io/pypi/l/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: License .. |Supported Python| image:: https://img.shields.io/pypi/pyversions/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Supported Python Versions .. |Format| image:: https://img.shields.io/pypi/format/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Format .. |Downloads| image:: https://img.shields.io/pypi/dm/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Downloads Keywords: graph visualization dot render Platform: any Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Scientific/Engineering :: Visualization graphviz-0.5.2/README.rst0000666000000000000000000001041413020607126013536 0ustar rootrootGraphviz ======== |PyPI version| |License| |Supported Python| |Format| |Downloads| This package facilitates the creation and rendering of graph descriptions in the DOT_ language of the Graphviz_ graph drawing software (repo_) from Python. Create a graph object, assemble the graph by adding nodes and edges, and retrieve its DOT source code string. Save the source code to a file and render it with the Graphviz installation of your system. Use the ``view`` option/method to directly inspect the resulting (PDF, PNG, SVG, etc.) file with its default application. Graphs can also be rendered and displayed within `Jupyter notebooks`_ (a.k.a. `IPython notebooks`_, example_). Links ----- - GitHub: http://github.com/xflr6/graphviz - PyPI: http://pypi.python.org/pypi/graphviz - Documentation: http://graphviz.readthedocs.io - Changelog: http://graphviz.readthedocs.io/en/latest/changelog.html - Issue Tracker: http://github.com/xflr6/graphviz/issues - Download: http://pypi.python.org/pypi/graphviz#downloads Installation ------------ This package runs under Python 2.6, 2.7, and 3.3+, use pip_ to install: .. code:: bash $ pip install graphviz To render the generated DOT source code, you also need to install Graphviz (`download page`_). Make sure that the directory containing the ``dot`` executable is on your systems' path. Quickstart ---------- Create a graph object: .. code:: python >>> from graphviz import Digraph >>> dot = Digraph(comment='The Round Table') >>> dot #doctest: +ELLIPSIS Add nodes and edges: .. code:: python >>> dot.node('A', 'King Arthur') >>> dot.node('B', 'Sir Bedevere the Wise') >>> dot.node('L', 'Sir Lancelot the Brave') >>> dot.edges(['AB', 'AL']) >>> dot.edge('B', 'L', constraint='false') Check the generated source code: .. code:: python >>> print(dot.source) # doctest: +NORMALIZE_WHITESPACE // The Round Table digraph { A [label="King Arthur"] B [label="Sir Bedevere the Wise"] L [label="Sir Lancelot the Brave"] A -> B A -> L B -> L [constraint=false] } Save and render the source code, optionally view the result: .. code:: python >>> dot.render('test-output/round-table.gv', view=True) 'test-output/round-table.gv.pdf' .. image:: https://raw.github.com/xflr6/graphviz/master/docs/round-table.png :align: center See also -------- - pygraphviz_ |--| full-blown interface wrapping the Graphviz C library with SWIG - graphviz-python_ |--| official Python bindings (documentation_) - pydot_ |--| stable pure-Python approach, requires pyparsing License ------- This package is distributed under the `MIT license`_. .. _pip: http://pip.readthedocs.io .. _Graphviz: http://www.graphviz.org .. _repo: http://github.com/ellson/graphviz/ .. _download page: http://www.graphviz.org/Download.php .. _DOT: http://www.graphviz.org/doc/info/lang.html .. _Jupyter notebooks: http://jupyter.org .. _IPython notebooks: http://ipython.org/notebook.html .. _example: http://nbviewer.jupyter.org/github/xflr6/graphviz/blob/master/examples/notebook.ipynb .. _pygraphviz: http://pypi.python.org/pypi/pygraphviz .. _graphviz-python: http://pypi.python.org/pypi/graphviz-python .. _documentation: http://www.graphviz.org/pdf/gv.3python.pdf .. _pydot: http://pypi.python.org/pypi/pydot .. _MIT license: http://opensource.org/licenses/MIT .. |--| unicode:: U+2013 .. |PyPI version| image:: https://img.shields.io/pypi/v/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Latest PyPI Version .. |License| image:: https://img.shields.io/pypi/l/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: License .. |Supported Python| image:: https://img.shields.io/pypi/pyversions/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Supported Python Versions .. |Format| image:: https://img.shields.io/pypi/format/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Format .. |Downloads| image:: https://img.shields.io/pypi/dm/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Downloads graphviz-0.5.2/requirements.txt0000666000000000000000000000022113020607130015321 0ustar rootroot# exact dependency versions used in development # dependencies for testing and building unittest2 nose coverage flake8 pep8-naming wheel graphviz-0.5.2/run-tests.py0000666000000000000000000000013713020607130014361 0ustar rootroot#!/usr/bin/env python # run-tests.py import sys import nose nose.main(sys.argv[1:]) graphviz-0.5.2/setup.cfg0000666000000000000000000000060413020607452013672 0ustar rootroot[sdist] formats = zip [bdist_wheel] universal = 1 [nosetests] tests = tests, graphviz, README.rst, docs/manual.rst verbosity = 1 with-doctest = 1 doctest-extension = .rst with-coverage = 1 cover-package = graphviz cover-html = 1 [flake8] ignore = E126,E128 max-line-length = 100 exclude = docs, .tox [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 graphviz-0.5.2/setup.py0000666000000000000000000000216213020607240013557 0ustar rootroot# setup.py from setuptools import setup, find_packages setup( name='graphviz', version='0.5.2', author='Sebastian Bank', author_email='sebastian.bank@uni-leipzig.de', description='Simple Python interface for Graphviz', keywords='graph visualization dot render', license='MIT', url='http://github.com/xflr6/graphviz', packages=find_packages(), platforms='any', long_description=open('README.rst').read(), classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Topic :: Scientific/Engineering :: Visualization', ], ) graphviz-0.5.2/docs/0000755000000000000000000000000013026663155013005 5ustar rootrootgraphviz-0.5.2/docs/api.rst0000666000000000000000000000231413020607126014302 0ustar rootroot.. _api: API Reference ============= .. note:: The two main classes ``Graph`` and ``Digraph`` (for creating `undirected` vs. `directed` graphs) have exactly the same API. Their division reflects the fact that both graph types cannot be mixed. Graph ----- .. autoclass:: graphviz.Graph :members: source, node, edge, edges, attr, subgraph, format, engine, encoding, pipe, save, render, view Digraph ------- .. autoclass:: graphviz.Digraph :members: source, node, edge, edges, attr, subgraph, format, engine, encoding, pipe, save, render, view Source ------ .. autoclass:: graphviz.Source :members: format, engine, encoding, pipe, save, render, view Low-level functions ------------------- The functions in this section are provided to work directly with existing files and strings instead of using the object-oriented DOT creation api above. .. autofunction:: graphviz.render .. autofunction:: graphviz.pipe .. autofunction:: graphviz.view Other ----- .. autodata:: graphviz.ENGINES :annotation: .. autodata:: graphviz.FORMATS :annotation: graphviz-0.5.2/docs/changelog.rst0000666000000000000000000000005313020607126015456 0ustar rootroot.. _changelog: .. include:: ../CHANGES graphviz-0.5.2/docs/conf.py0000666000000000000000000002313413020607300014273 0ustar rootroot# -*- coding: utf-8 -*- # # graphviz documentation build configuration file, created by # sphinx-quickstart on Sat Jan 03 12:26:47 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath(os.pardir)) import graphviz # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.intersphinx', ] intersphinx_mapping = { 'py': ('http://docs.python.org/2', None), 'py3': ('http://docs.python.org/3', None), } # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'graphviz' copyright = u'2013-2016, Sebastian Bank' author = u'Sebastian Bank' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = release = '0.5.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' #html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value #html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'graphvizdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', # Latex figure (float) alignment #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'graphviz.tex', u'graphviz Documentation', u'Sebastian Bank', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'graphviz', u'graphviz Documentation', [author], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'graphviz', u'graphviz Documentation', author, 'graphviz', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False graphviz-0.5.2/docs/examples.rst0000666000000000000000000000215413020607126015351 0ustar rootroot.. _examples: Examples ======== See the ``examples`` directory in the `source repository/distribution`__. .. __: http://github.com/xflr6/graphviz/tree/master/examples/ hello.py -------- .. literalinclude:: ../examples/hello.py :lines: 2- .. image:: _static/hello.svg :align: center process.py ---------- .. literalinclude:: ../examples/process.py :lines: 2- .. image:: _static/process.svg :align: center fsm.py ------ .. literalinclude:: ../examples/fsm.py :lines: 2- .. image:: _static/fsm.svg :align: center cluster.py ---------- .. literalinclude:: ../examples/cluster.py :lines: 2- .. image:: _static/cluster.svg :align: center er.py ----- .. literalinclude:: ../examples/er.py :lines: 2- .. image:: _static/er.svg :align: center unix.py ------- .. literalinclude:: ../examples/unix.py :lines: 2- .. image:: _static/unix.svg :align: center structs.py ---------- .. literalinclude:: ../examples/structs.py :lines: 2- .. image:: _static/structs.svg :align: center graphviz-0.5.2/docs/index.rst0000666000000000000000000000061213020607126014637 0ustar rootroot.. graphviz documentation master file .. include:: ../README.rst User Guide ========== .. toctree:: :maxdepth: 2 manual Examples ======== .. toctree:: :maxdepth: 2 examples API Reference ============= .. toctree:: :maxdepth: 2 api Project Info ============ .. toctree:: :maxdepth: 2 changelog license graphviz-0.5.2/docs/license.rst0000666000000000000000000000007513020607126015155 0ustar rootroot.. _license: License ======= .. include:: ../LICENSE graphviz-0.5.2/docs/manual.rst0000666000000000000000000001721513020607126015014 0ustar rootroot.. _manual: User Guide ========== Installation ------------ :mod:`graphviz` provides a simple pure-Python interface for the Graphviz_ graph-drawing software. It runs under Python 2.6, 2.7 and 3.3+. To install it with pip_ run the following: .. code:: bash $ pip install graphviz For a system-wide install, this typically requires administrator access. For an isolated install, you can run the same inside a virtualenv_ or a :mod:`py3:venv` (Python 3.3+ only). The only dependency is a working installation of Graphviz (`download page`_). After installing Graphviz, make sure that its ``bin/`` subdirectory containing the layout commands for rendering graph descriptions (``dot``, ``circo``, ``neato``, etc.) is on your systems' path: On the command-line, ``dot -V`` should print the version of your Graphiz installation. Basic usage ----------- The :mod:`graphviz` module provides two classes: :class:`.Graph` and :class:`.Digraph`. They create graph descriptions in the DOT_ language for undirected and directed graphs respectively. They have the same :ref:`API `. Create a graph by instantiating a new :class:`.Graph` or :class:`.Digraph` object: .. code:: python >>> from graphviz import Digraph >>> dot = Digraph(comment='The Round Table') >>> dot #doctest: +ELLIPSIS Their constructors allow to set the graph's :attr:`~.Graph.name`, the :attr:`~.Graph.filename` for the DOT source and the rendered graph, a :attr:`~.Graph.comment` for the first source code line, etc. Add nodes and edges to the graph object using its :meth:`~.Graph.node` and :meth:`~.Graph.edge` or :meth:`~.Graph.edges` methods: .. code:: python >>> dot.node('A', 'King Arthur') >>> dot.node('B', 'Sir Bedevere the Wise') >>> dot.node('L', 'Sir Lancelot the Brave') >>> dot.edges(['AB', 'AL']) >>> dot.edge('B', 'L', constraint='false') The :meth:`~.Graph.node`-method takes a ``name`` identifier as first argument and an optional ``label``. The :meth:`~.Graph.edge`-method takes the names of start- and end-node, while :meth:`~.Graph.edges` takes iterable of name-pairs. Keyword arguments are turned into (node and edge) attributes (see `Graphviz docs `_). Check the generated source code: .. code:: python >>> print(dot.source) # doctest: +NORMALIZE_WHITESPACE // The Round Table digraph { A [label="King Arthur"] B [label="Sir Bedevere the Wise"] L [label="Sir Lancelot the Brave"] A -> B A -> L B -> L [constraint=false] } Use the :meth:`~.Graph.render`-method to save the source code and render it with the default layout program (``dot``, see below for using `other layout commands `_). .. code:: python >>> dot.render('test-output/round-table.gv', view=True) 'test-output/round-table.gv.pdf' .. image:: _static/round-table.svg :align: center Passing ``view=True`` will automatically open the resulting (PDF, PNG, SVG, etc.) file with your system's default viewer application for the file type. Formats ------- To use a different `output file format`_ than the default PDF, use the :attr:`~.Graph.format` argument when creating your :class:`.Graph` or :class:`.Digraph` object: .. code:: python >>> from graphviz import Graph >>> g = Graph(format='png') You can also change the :attr:`~.Graph.format` attribute on an existing graph object: .. code:: python >>> dot.format = 'svg' >>> dot.render() 'test-output/round-table.gv.svg' Piped output ------------ To directly access the results from the Graphviz rendering command (e.g. ``dot``) as binary data string from within Python instead of writing to a file, use the :meth:`~.Graph.pipe`-method of your :class:`.Graph` or :class:`.Digraph` object: .. code:: python >>> h = Graph('hello', format='svg') >>> h.edge('Hello', 'World') >>> print(h.pipe().decode('utf-8')) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS Note that :meth:`~.Graph.pipe` returns the raw ``stdout`` from the rendering command (``str`` on Python 2, ``bytes`` on Python 3): When piping into plain-text formats like ``svg`` or ``plain``, you usually want to decode the return value as shown above. .. note:: The output for :meth:`~.Graph.pipe` is buffered in memory, so do not use this method if the data size is large. Jupyter notebooks ----------------- :class:`.Graph` and :class:`.Digraph` objects have a :meth:`~.Graph._repr_svg_`-method so they can be rendered and displayed directly inside a `Jupyter notebook`_. For an example, check the ``examples/notebook.ipynb`` file in the `source repository/distribution `_ (nbviewer_). Styling ------- Use the :attr:`~.Graph.graph_attr`, :attr:`~.Graph.node_attr`, and :attr:`~.Graph.edge_attr` arguments to change the default appearance_ of your graph, nodes, and edges. .. code:: python >>> dot = Digraph(name='pet-shop', node_attr={'shape': 'plaintext'}) >>> dot.node('parrot') >>> dot.node('dead') >>> dot.edge('parrot', 'dead') After creation, they can be edited on the graph object: .. code:: python >>> dot.graph_attr['rankdir'] = 'LR' >>> dot.edge_attr.update(arrowhead='vee', arrowsize='2') >>> print(dot.source) # doctest: +NORMALIZE_WHITESPACE digraph "pet-shop" { graph [rankdir=LR] node [shape=plaintext] edge [arrowhead=vee arrowsize=2] parrot dead parrot -> dead } .. image:: _static/pet-shop.svg :align: center Engines ------- To use a different layout command than the default ``dot`` when rendering your graph, use the :attr:`~.Graph.engine` argument when creating your graph. .. code:: python >>> g = Graph(engine='neato') You can also change the :attr:`~.Graph.engine` attribute of an existing instance: .. code:: python >>> dot.engine = 'circo' Using raw DOT ------------- To render a ready-made DOT source code string (instead of assembling one with the higher-level interface of :class:`.Graph` or :class:`.Digraph`), create a :class:`.Source` object holding your DOT string: .. code:: python >>> from graphviz import Source >>> src = Source('digraph "the holy hand grenade" { rankdir=LR; 1 -> 2 -> 3 -> lob }') >>> src #doctest: +ELLIPSIS Use the :meth:`~.Source.render`-method to save and render it: .. code:: python >>> src.render('test-output/holy-grenade.gv', view=True) 'test-output/holy-grenade.gv.pdf' .. image:: _static/holy-grenade.svg :align: center Apart from the missing editing methods, :class:`.Source` objects are the same as the higher-level graph objects (:meth:`~.Source.pipe`-method, :attr:`~.Source.format`, :attr:`~.Source.engine`, Jupyter notebook repr, etc.), see above. .. _pip: http://pip.readthedocs.io .. _virtualenv: http://virtualenv.pypa.io .. _Graphviz: http://www.graphviz.org .. _download page: http://www.graphviz.org/Download.php .. _DOT: http://www.graphviz.org/doc/info/lang.html .. _output file format: http://www.graphviz.org/doc/info/output.html .. _appearance: http://www.graphviz.org/doc/info/attrs.html .. _Jupyter notebook: http://jupyter.org .. _notebook: http://github.com/xflr6/graphviz/blob/master/examples/notebook.ipynb .. _nbviewer: http://nbviewer.jupyter.org/github/xflr6/graphviz/blob/master/examples/notebook.ipynb graphviz-0.5.2/docs/pet-shop.png0000666000000000000000000000346113020607126015250 0ustar rootrootPNG  IHDR;i~*bKGDIDATxMh[w23 ]ⲕv!(TЅ"T7FK5.JpU "(.. j]hBI|wq;Id=3s9ofU!"cl%0*8,I0&˜$ c8,I0&˜$ c8,I0&˜$ c8,I0&$be 8,Mׯ_Dgg'.\/_]+033ĶmpI{ʘV<$W(ؿ?B6 fcy4 Dϟcxx}}}w.s4.|wif>ԩSغu+nܸE+-oaaя֙T*Ec/--ѡCHUU4'K-b[5h4a!"f IQ ]IQ:x xr4j72,6,N~!MUUܼyׯ_/pd@Dx ݋~<|us(ADDe2Md޶T> 8NqR~TH=eY1pѻs{. %2HUURoN۷w0(L_qhbb.|:m@^`D8d۶*""0H$4ͲadY{b pUXc+1ޗ(*m޼^J?k]ai8{߰q>"b1@D*χj?*>Hpp`'NJbF=Ak%^4b`Ku4N8Ao߾y=F(Q,&<ds5PR[\<T j~Wʳmm((#`ΝB8|04Og=wJUmd2nPCCCx^~#GpPaǷbS8pKKKE41\t ===>W6ñv=ѣGݐtttŋ8{,ls_uww7B?6+cibnno>\r###T4KX^^vDZk.+bpX y?+fl-8,I0&˜$ c8,I0&˜$ c8,I0&˜$ c8,I0&IE0WJv&IENDB`graphviz-0.5.2/docs/requirements.txt0000666000000000000000000000003713020607126016263 0ustar rootrootsphinx>=1.3 sphinx-rtd-theme graphviz-0.5.2/docs/round-table.png0000666000000000000000000003546013020607126015731 0ustar rootrootPNG  IHDRcbKGD IDATx{Two \pQ** T"jEe{9=}g=}}nZ[[]iXE[PV$@-&!pH2gg&"!B; BB!P@!nB@Zh4h4hiiA[[Z[[u:48nnn\\\WWWH$H$xzz2B :UUUDUUP[[ BRZBVCv6X7xyy&M”)S0ydbDԋ܌7o ***PQQ\*tuu?\]]OOO~G H$~~vvv0AR05477ojPThnnFASS_Bb1 "$$9s&܆%X BPXX\᧟~O?*+MP J>>>D/EcP(娬DEEnOwHR̜9fœ9s0888MT 2 c駟(,,D{{;Ə9s`֬Y AXXfΜ@/Jף%%%(..[NR쌈DEE!::9sa2&P@`.\@ff&233T*#::L>]pmc ?3rssǵkנh%K ..K,YQ BISS;ٳP*%Kxb,]f͂.^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~,&Bƺo˗7nj\ ޽{QXX3f`X`8@&.\~;"33Gnn.,Y"thŋ~ѣGq5̞=>(.]$th ---ؿ?j*xyyʕ+Oo\{1&L^zscBFJ{=6k,w}СC͖t:石X>~BѠ ӓ9;;^ ֪ŁG-#'|'Nд\ pz=Ν;/hllDll,~a$&&"((h0fCȨ܌SN!%%ONҥKalذnnnB8(p|嗸pzjb„ 8q"&L@MC hhh@MM  P(PSS_]] Vˏd6sO2b[Q\۷oɓ'󃿿????>WЍc hhh@}}=J%QSS;w𹣪 J:wfs;;*V#j(J9rԠ۸\`X4>wssD"!H wwwxxx+ۛjhZ FF tttMŅO\B5Wč =`pGvF;qtt#La~0dQ^Z&Rjd6Go 3:3c$POP*JYWWgvf_tqqw=pH$ppp3ƍX 777Dn}c-},u:4q4QjсvkjjBWWqk4j-i#12"477םsn|!?ۿ;'''8:: 1}n7n7}܌Nj|!JBss34M9ͭe/ì?z掦ۙjZ~2Z[[m#q+28EiIK$0yzz-(GEt9!ݵmmh4Z ^ommmF;_nmΞSQftG\K7H$Fyg|ZY|!HL+B!P9F!n@ BH7T B!1B!&pi5IENDB`graphviz-0.5.2/docs/_static/0000755000000000000000000000000013026663155014433 5ustar rootrootgraphviz-0.5.2/docs/_static/cluster.svg0000666000000000000000000002031213020607126016625 0ustar rootroot G cluster_0 process #1 cluster_1 process #2 a0 a0 a1 a1 a0->a1 a2 a2 a1->a2 b3 b3 a1->b3 a3 a3 a2->a3 a3->a0 end end a3->end b0 b0 b1 b1 b0->b1 b2 b2 b1->b2 b2->a3 b2->b3 b3->end start start start->a0 start->b0 graphviz-0.5.2/docs/_static/er.svg0000666000000000000000000001730313020607126015560 0ustar rootroot ER Entity Relation Diagram drawn by NEATO course course C-I C-I course--C-I n institute institute name1 name institute--name1 S-I S-I institute--S-I 1 student student name2 name student--name2 grade grade student--grade number number student--number S-C S-C student--S-C m name0 name name0--course code code code--course C-I--institute 1 S-C--course n S-I--student n graphviz-0.5.2/docs/_static/fsm.svg0000666000000000000000000002354413020607126015743 0ustar rootroot finite_state_machine LR_0 LR_0 LR_2 LR_2 LR_0->LR_2 SS(B) LR_1 LR_1 LR_0->LR_1 SS(S) LR_3 LR_3 LR_4 LR_4 LR_8 LR_8 LR_6 LR_6 LR_8->LR_6 S(b) LR_5 LR_5 LR_8->LR_5 S(a) LR_2->LR_4 S(A) LR_2->LR_6 SS(b) LR_2->LR_5 SS(a) LR_1->LR_3 S($end) LR_6->LR_6 S(b) LR_6->LR_5 S(a) LR_5->LR_5 S(a) LR_7 LR_7 LR_5->LR_7 S(b) LR_7->LR_8 S(b) LR_7->LR_5 S(a) graphviz-0.5.2/docs/_static/hello.svg0000666000000000000000000000266513020607126016262 0ustar rootroot G Hello Hello World World Hello->World graphviz-0.5.2/docs/_static/holy-grenade.svg0000666000000000000000000000464213020607126017532 0ustar rootroot the holy hand grenade 1 1 2 2 1->2 3 3 2->3 lob lob 3->lob graphviz-0.5.2/docs/_static/pet-shop.svg0000666000000000000000000000250513020607126016707 0ustar rootroot pet-shop parrot parrot dead dead parrot->dead graphviz-0.5.2/docs/_static/process.svg0000666000000000000000000001371413020607126016632 0ustar rootroot G run run intr intr run--intr kernel kernel run--kernel runbl runbl intr--runbl runbl--run zombie zombie kernel--zombie sleep sleep kernel--sleep runmem runmem kernel--runmem sleep--runmem swap swap sleep--swap runswap runswap swap--runswap runswap--runmem new new runswap--new new--runmem graphviz-0.5.2/docs/_static/round-table.svg0000666000000000000000000000443313020607126017366 0ustar rootroot %3 A King Arthur B Sir Bedevere the Wise A->B L Sir Lancelot the Brave A->L B->L graphviz-0.5.2/docs/_static/structs.svg0000666000000000000000000001045313020607126016660 0ustar rootroot structs struct1 left middle right struct2 one two struct1:f1->struct2:f0 struct3 hello world b g h c d e f struct1:f2->struct3:here graphviz-0.5.2/docs/_static/unix.svg0000666000000000000000000007167713020607126016153 0ustar rootroot unix 5th Edition 5th Edition 6th Edition 6th Edition 5th Edition->6th Edition PWB 1.0 PWB 1.0 5th Edition->PWB 1.0 LSX LSX 6th Edition->LSX 1 BSD 1 BSD 6th Edition->1 BSD Mini Unix Mini Unix 6th Edition->Mini Unix Wollongong Wollongong 6th Edition->Wollongong Interdata Interdata 6th Edition->Interdata PWB 1.2 PWB 1.2 PWB 1.0->PWB 1.2 USG 1.0 USG 1.0 PWB 1.0->USG 1.0 2 BSD 2 BSD 1 BSD->2 BSD Unix/TS 3.0 Unix/TS 3.0 Interdata->Unix/TS 3.0 PWB 2.0 PWB 2.0 Interdata->PWB 2.0 7th Edition 7th Edition Interdata->7th Edition TS 4.0 TS 4.0 Unix/TS 3.0->TS 4.0 PWB 2.0->Unix/TS 3.0 8th Edition 8th Edition 7th Edition->8th Edition 32V 32V 7th Edition->32V V7M V7M 7th Edition->V7M Ultrix-11 Ultrix-11 7th Edition->Ultrix-11 Xenix Xenix 7th Edition->Xenix UniPlus+ UniPlus+ 7th Edition->UniPlus+ 9th Edition 9th Edition 8th Edition->9th Edition 3 BSD 3 BSD 32V->3 BSD V7M->Ultrix-11 2.8 BSD 2.8 BSD 2 BSD->2.8 BSD 2.8 BSD->Ultrix-11 2.9 BSD 2.9 BSD 2.8 BSD->2.9 BSD 4 BSD 4 BSD 3 BSD->4 BSD 4.1 BSD 4.1 BSD 4 BSD->4.1 BSD 4.1 BSD->8th Edition 4.1 BSD->2.8 BSD 4.2 BSD 4.2 BSD 4.1 BSD->4.2 BSD 4.3 BSD 4.3 BSD 4.2 BSD->4.3 BSD Ultrix-32 Ultrix-32 4.2 BSD->Ultrix-32 PWB 1.2->PWB 2.0 CB Unix 1 CB Unix 1 USG 1.0->CB Unix 1 USG 2.0 USG 2.0 USG 1.0->USG 2.0 CB Unix 2 CB Unix 2 CB Unix 1->CB Unix 2 USG 3.0 USG 3.0 USG 2.0->USG 3.0 CB Unix 3 CB Unix 3 CB Unix 2->CB Unix 3 Unix/TS++ Unix/TS++ CB Unix 3->Unix/TS++ PDP-11 Sys V PDP-11 Sys V CB Unix 3->PDP-11 Sys V CB Unix 3->TS 4.0 Unix/TS++->TS 4.0 USG 3.0->Unix/TS 3.0 Unix/TS 1.0 Unix/TS 1.0 Unix/TS 1.0->Unix/TS 3.0 System V.0 System V.0 TS 4.0->System V.0 System V.2 System V.2 System V.0->System V.2 System V.3 System V.3 System V.2->System V.3 graphviz-0.5.2/examples/0000755000000000000000000000000013026663155013673 5ustar rootrootgraphviz-0.5.2/examples/cluster.py0000666000000000000000000000152313020607130015714 0ustar rootroot#!/usr/bin/env python # cluster.py - http://www.graphviz.org/content/cluster from graphviz import Digraph g = Digraph('G', filename='cluster.gv') c0 = Digraph('cluster_0') c0.body.append('style=filled') c0.body.append('color=lightgrey') c0.node_attr.update(style='filled', color='white') c0.edges([('a0', 'a1'), ('a1', 'a2'), ('a2', 'a3')]) c0.body.append('label = "process #1"') c1 = Digraph('cluster_1') c1.node_attr.update(style='filled') c1.edges([('b0', 'b1'), ('b1', 'b2'), ('b2', 'b3')]) c1.body.append('label = "process #2"') c1.body.append('color=blue') g.subgraph(c0) g.subgraph(c1) g.edge('start', 'a0') g.edge('start', 'b0') g.edge('a1', 'b3') g.edge('b2', 'a3') g.edge('a3', 'a0') g.edge('a3', 'end') g.edge('b3', 'end') g.node('start', shape='Mdiamond') g.node('end', shape='Msquare') g.view() graphviz-0.5.2/examples/er.py0000666000000000000000000000213613020607130014642 0ustar rootroot#!/usr/bin/env python # er.py - http://www.graphviz.org/content/ER from graphviz import Graph e = Graph('ER', filename='er.gv', engine='neato') e.attr('node', shape='box') e.node('course') e.node('institute') e.node('student') e.attr('node', shape='ellipse') e.node('name0', label='name') e.node('name1', label='name') e.node('name2', label='name') e.node('code') e.node('grade') e.node('number') e.attr('node', shape='diamond', style='filled', color='lightgrey') e.node('C-I') e.node('S-C') e.node('S-I') e.edge('name0', 'course') e.edge('code', 'course') e.edge('course', 'C-I', label='n', len='1.00') e.edge('C-I', 'institute', label='1', len='1.00') e.edge('institute', 'name1') e.edge('institute', 'S-I', label='1', len='1.00') e.edge('S-I', 'student', label='n', len='1.00') e.edge('student', 'grade') e.edge('student', 'name2') e.edge('student', 'number') e.edge('student', 'S-C', label='m', len='1.00') e.edge('S-C', 'course', label='n', len='1.00') e.body.append(r'label = "\n\nEntity Relation Diagram\ndrawn by NEATO"') e.body.append('fontsize=20') e.view() graphviz-0.5.2/examples/fsm.py0000666000000000000000000000157713020607130015031 0ustar rootroot#!/usr/bin/env python # fsm.py - http://www.graphviz.org/content/fsm from graphviz import Digraph f = Digraph('finite_state_machine', filename='fsm.gv') f.body.extend(['rankdir=LR', 'size="8,5"']) f.attr('node', shape='doublecircle') f.node('LR_0') f.node('LR_3') f.node('LR_4') f.node('LR_8') f.attr('node', shape='circle') f.edge('LR_0', 'LR_2', label='SS(B)') f.edge('LR_0', 'LR_1', label='SS(S)') f.edge('LR_1', 'LR_3', label='S($end)') f.edge('LR_2', 'LR_6', label='SS(b)') f.edge('LR_2', 'LR_5', label='SS(a)') f.edge('LR_2', 'LR_4', label='S(A)') f.edge('LR_5', 'LR_7', label='S(b)') f.edge('LR_5', 'LR_5', label='S(a)') f.edge('LR_6', 'LR_6', label='S(b)') f.edge('LR_6', 'LR_5', label='S(a)') f.edge('LR_7', 'LR_8', label='S(b)') f.edge('LR_7', 'LR_5', label='S(a)') f.edge('LR_8', 'LR_6', label='S(b)') f.edge('LR_8', 'LR_5', label='S(a)') f.view() graphviz-0.5.2/examples/hello.py0000666000000000000000000000027413020607130015340 0ustar rootroot#!/usr/bin/env python # hello.py - http://www.graphviz.org/content/hello from graphviz import Digraph g = Digraph('G', filename='hello.gv') g.edge('Hello', 'World') g.view() graphviz-0.5.2/examples/notebook.ipynb0000666000000000000000000001752213020607130016552 0ustar rootroot{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/svg+xml": [ "\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "%3\r\n", "\r\n", "\r\n", "A\r\n", "\r\n", "King Arthur\r\n", "\r\n", "\r\n", "B\r\n", "\r\n", "Sir Bedevere the Wise\r\n", "\r\n", "\r\n", "A->B\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "L\r\n", "\r\n", "Sir Lancelot the Brave\r\n", "\r\n", "\r\n", "A->L\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "B->L\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from graphviz import Digraph\n", "\n", "dot = Digraph(comment='The Round Table')\n", "\n", "dot.node('A', 'King Arthur')\n", "dot.node('B', 'Sir Bedevere the Wise')\n", "dot.node('L', 'Sir Lancelot the Brave')\n", "\n", "dot.edges(['AB', 'AL'])\n", "dot.edge('B', 'L', constraint='false')\n", "\n", "dot" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/svg+xml": [ "\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "the holy hand grenade\r\n", "\r\n", "\r\n", "1\r\n", "\r\n", "1\r\n", "\r\n", "\r\n", "2\r\n", "\r\n", "2\r\n", "\r\n", "\r\n", "1->2\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "3\r\n", "\r\n", "3\r\n", "\r\n", "\r\n", "2->3\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "lob\r\n", "\r\n", "lob\r\n", "\r\n", "\r\n", "3->lob\r\n", "\r\n", "\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from graphviz import Source\n", "\n", "src = Source('digraph \"the holy hand grenade\" { rankdir=LR; 1 -> 2 -> 3 -> lob }')\n", "src" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 0 } graphviz-0.5.2/examples/process.py0000666000000000000000000000100613020607130015705 0ustar rootroot#!/usr/bin/env python # process.py - http://www.graphviz.org/content/process from graphviz import Graph g = Graph('G', filename='process.gv', engine='sfdp') g.edge('run', 'intr') g.edge('intr', 'runbl') g.edge('runbl', 'run') g.edge('run', 'kernel') g.edge('kernel', 'zombie') g.edge('kernel', 'sleep') g.edge('kernel', 'runmem') g.edge('sleep', 'swap') g.edge('swap', 'runswap') g.edge('runswap', 'new') g.edge('runswap', 'runmem') g.edge('new', 'runmem') g.edge('sleep', 'runmem') g.view() graphviz-0.5.2/examples/structs.py0000666000000000000000000000172513020607130015746 0ustar rootroot#!/usr/bin/env python # structs.py - http://www.graphviz.org/doc/info/shapes.html#html from graphviz import Digraph s = Digraph('structs', node_attr={'shape': 'plaintext'}) s.node('struct1', '''<
left middle right
>''') s.node('struct2', '''<
one two
>''') s.node('struct3', '''<
hello
world
b g h
c d e
f
>''') s.edges([('struct1:f1', 'struct2:f0'), ('struct1:f2', 'struct3:here')]) s.view() graphviz-0.5.2/examples/unix.py0000666000000000000000000000345513020607130015224 0ustar rootroot#!/usr/bin/env python # unix.py - http://www.graphviz.org/content/unix from graphviz import Digraph u = Digraph('unix', filename='unix.gv') u.body.append('size="6,6"') u.node_attr.update(color='lightblue2', style='filled') u.edge('5th Edition', '6th Edition') u.edge('5th Edition', 'PWB 1.0') u.edge('6th Edition', 'LSX') u.edge('6th Edition', '1 BSD') u.edge('6th Edition', 'Mini Unix') u.edge('6th Edition', 'Wollongong') u.edge('6th Edition', 'Interdata') u.edge('Interdata', 'Unix/TS 3.0') u.edge('Interdata', 'PWB 2.0') u.edge('Interdata', '7th Edition') u.edge('7th Edition', '8th Edition') u.edge('7th Edition', '32V') u.edge('7th Edition', 'V7M') u.edge('7th Edition', 'Ultrix-11') u.edge('7th Edition', 'Xenix') u.edge('7th Edition', 'UniPlus+') u.edge('V7M', 'Ultrix-11') u.edge('8th Edition', '9th Edition') u.edge('1 BSD', '2 BSD') u.edge('2 BSD', '2.8 BSD') u.edge('2.8 BSD', 'Ultrix-11') u.edge('2.8 BSD', '2.9 BSD') u.edge('32V', '3 BSD') u.edge('3 BSD', '4 BSD') u.edge('4 BSD', '4.1 BSD') u.edge('4.1 BSD', '4.2 BSD') u.edge('4.1 BSD', '2.8 BSD') u.edge('4.1 BSD', '8th Edition') u.edge('4.2 BSD', '4.3 BSD') u.edge('4.2 BSD', 'Ultrix-32') u.edge('PWB 1.0', 'PWB 1.2') u.edge('PWB 1.0', 'USG 1.0') u.edge('PWB 1.2', 'PWB 2.0') u.edge('USG 1.0', 'CB Unix 1') u.edge('USG 1.0', 'USG 2.0') u.edge('CB Unix 1', 'CB Unix 2') u.edge('CB Unix 2', 'CB Unix 3') u.edge('CB Unix 3', 'Unix/TS++') u.edge('CB Unix 3', 'PDP-11 Sys V') u.edge('USG 2.0', 'USG 3.0') u.edge('USG 3.0', 'Unix/TS 3.0') u.edge('PWB 2.0', 'Unix/TS 3.0') u.edge('Unix/TS 1.0', 'Unix/TS 3.0') u.edge('Unix/TS 3.0', 'TS 4.0') u.edge('Unix/TS++', 'TS 4.0') u.edge('CB Unix 3', 'TS 4.0') u.edge('TS 4.0', 'System V.0') u.edge('System V.0', 'System V.2') u.edge('System V.2', 'System V.3') u.view() graphviz-0.5.2/graphviz/0000755000000000000000000000000013026663155013707 5ustar rootrootgraphviz-0.5.2/graphviz/backend.py0000666000000000000000000001074413020607130015643 0ustar rootroot# backend.py - execute rendering, open files in viewer import os import errno import platform import subprocess from . import tools __all__ = ['render', 'pipe', 'view'] ENGINES = set([ # http://www.graphviz.org/cgi-bin/man?dot 'dot', 'neato', 'twopi', 'circo', 'fdp', 'sfdp', 'patchwork', 'osage', ]) FORMATS = set([ # http://www.graphviz.org/doc/info/output.html 'bmp', 'canon', 'dot', 'gv', 'xdot', 'xdot1.2', 'xdot1.4', 'cgimage', 'cmap', 'eps', 'exr', 'fig', 'gd', 'gd2', 'gif', 'gtk', 'ico', 'imap', 'cmapx', 'imap_np', 'cmapx_np', 'ismap', 'jp2', 'jpg', 'jpeg', 'jpe', 'pct', 'pict', 'pdf', 'pic', 'plain', 'plain-ext', 'png', 'pov', 'ps', 'ps2', 'psd', 'sgi', 'svg', 'svgz', 'tga', 'tif', 'tiff', 'tk', 'vml', 'vmlz', 'vrml', 'wbmp', 'webp', 'xlib', 'x11', ]) PLATFORM = platform.system().lower() STARTUPINFO = None if PLATFORM == 'windows': # pragma: no cover STARTUPINFO = subprocess.STARTUPINFO() STARTUPINFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW STARTUPINFO.wShowWindow = subprocess.SW_HIDE def command(engine, format, filepath=None): """Return args list for subprocess.Popen and name of the rendered file.""" if engine not in ENGINES: raise ValueError('unknown engine: %r' % engine) if format not in FORMATS: raise ValueError('unknown format: %r' % format) args, rendered = [engine, '-T%s' % format], None if filepath is not None: args.extend(['-O', filepath]) rendered = '%s.%s' % (filepath, format) return args, rendered def render(engine, format, filepath): """Render file with Graphviz engine into format, return result filename. Args: engine: The layout commmand used for rendering ('dot', 'neato', ...). format: The output format used for rendering ('pdf', 'png', ...). filepath: Path to the DOT source file to render. Returns: The (possibly relative) path of the rendered file. Raises: RuntimeError: If the Graphviz executable is not found. """ args, rendered = command(engine, format, filepath) try: subprocess.call(args, startupinfo=STARTUPINFO) except OSError as e: if e.errno == errno.ENOENT: raise RuntimeError('failed to execute %r, ' 'make sure the Graphviz executables ' 'are on your systems\' path' % args) else: # pragma: no cover raise return rendered def pipe(engine, format, data): """Return data piped through Graphviz engine into format. Args: engine: The layout commmand used for rendering ('dot', 'neato', ...). format: The output format used for rendering ('pdf', 'png', ...). data: The binary (encoded) DOT source string to render. Returns: Binary (encoded) stdout of the layout command. Raises: RuntimeError: If the Graphviz executable is not found. """ args, _ = command(engine, format) try: proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=STARTUPINFO) except OSError as e: if e.errno == errno.ENOENT: raise RuntimeError('failed to execute %r, ' 'make sure the Graphviz executables ' 'are on your systems\' path' % args) else: # pragma: no cover raise outs, errs = proc.communicate(data) return outs def view(filepath): """Open filepath with its default viewing application (platform-specific). Raises: RuntimeError: If the current platform is not supported. """ try: view_func = getattr(view, PLATFORM) except KeyError: raise RuntimeError('platform %r not supported' % PLATFORM) view_func(filepath) @tools.attach(view, 'darwin') def view_darwin(filepath): """Open filepath with its default application (mac).""" subprocess.Popen(['open', filepath]) @tools.attach(view, 'linux') def view_linux(filepath): """Open filepath in the user's preferred application (linux).""" subprocess.Popen(['xdg-open', filepath]) @tools.attach(view, 'windows') def view_windows(filepath): """Start filepath with its associated application (windows).""" os.startfile(os.path.normpath(filepath)) graphviz-0.5.2/graphviz/dot.py0000666000000000000000000001510313020607130015034 0ustar rootroot# dot.py - create dot code r"""Assemble DOT source code objects. >>> dot = Graph(comment=u'M\xf8nti Pyth\xf8n ik den H\xf8lie Grailen') >>> dot.node(u'M\xf8\xf8se') >>> dot.node('trained_by', u'trained by') >>> dot.node('tutte', u'TUTTE HERMSGERVORDENBROTBORDA') >>> dot.edge(u'M\xf8\xf8se', 'trained_by') >>> dot.edge('trained_by', 'tutte') >>> dot.node_attr['shape'] = 'rectangle' >>> print(dot.source.replace(u'\xf8', '0')) #doctest: +NORMALIZE_WHITESPACE // M0nti Pyth0n ik den H0lie Grailen graph { node [shape=rectangle] "M00se" trained_by [label="trained by"] tutte [label="TUTTE HERMSGERVORDENBROTBORDA"] "M00se" -- trained_by trained_by -- tutte } >>> dot.view('test-output/m00se.gv') 'test-output/m00se.gv.pdf' """ from . import lang, files __all__ = ['Graph', 'Digraph'] class Dot(files.File): """Assemble, save, and render DOT source code, open result in viewer.""" _comment = '// %s' _subgraph = 'subgraph %s{' _node = '\t%s%s' _tail = '}' quote = staticmethod(lang.quote) quote_edge = staticmethod(lang.quote_edge) attributes = staticmethod(lang.attributes) def __init__(self, name=None, comment=None, filename=None, directory=None, format=None, engine=None, encoding=None, graph_attr=None, node_attr=None, edge_attr=None, body=None, strict=False): self.name = name self.comment = comment super(Dot, self).__init__(filename, directory, format, engine, encoding) self.graph_attr = dict(graph_attr) if graph_attr is not None else {} self.node_attr = dict(node_attr) if node_attr is not None else {} self.edge_attr = dict(edge_attr) if edge_attr is not None else {} self.body = list(body) if body is not None else [] self.strict = strict def __iter__(self, subgraph=False): """Yield the DOT source code line by line.""" if self.comment: yield self._comment % self.comment head = self._subgraph if subgraph else self._head if self.strict: head = 'strict %s' % head yield head % (self.quote(self.name) + ' ' if self.name else '') styled = False for kw in ('graph', 'node', 'edge'): attr = getattr(self, '%s_attr' % kw) if attr: styled = True yield '\t%s%s' % (kw, self.attributes(None, attr)) indent = '\t' * styled for line in self.body: yield indent + line yield self._tail def __str__(self): return '\n'.join(self) source = property(__str__, doc='The DOT source code as string.') def node(self, name, label=None, _attributes=None, **attrs): """Create a node. Args: name: Unique identifier for the node inside the source. label: Caption to be displayed (defaults to the node name). attrs: Any additional node attributes (must be strings). """ name = self.quote(name) attributes = self.attributes(label, attrs, _attributes) self.body.append(self._node % (name, attributes)) def edge(self, tail_name, head_name, label=None, _attributes=None, **attrs): """Create an edge between two nodes. Args: tail_name: Start node identifier. head_name: End node identifier. label: Caption to be displayed near the edge. attrs: Any additional edge attributes (must be strings). """ tail_name = self.quote_edge(tail_name) head_name = self.quote_edge(head_name) attributes = self.attributes(label, attrs, _attributes) edge = self._edge % (tail_name, head_name, attributes) self.body.append(edge) def edges(self, tail_head_iter): """Create a bunch of edges. Args: tail_head_iter: Iterable of (tail_name, head_name) pairs. """ edge = self._edge_plain quote = self.quote_edge self.body.extend(edge % (quote(t), quote(h)) for t, h in tail_head_iter) def attr(self, kw, _attributes=None, **attrs): """Add a graph/node/edge attribute statement. Args: kw: Attributes target ('graph', 'node', or 'edge'). attrs: Attributes to be set (must be strings, may be empty). """ if kw.lower() not in ('graph', 'node', 'edge'): raise ValueError('attr statement must target graph, node, or edge: ' '%r' % kw) if _attributes or attrs: line = '\t%s%s' % (kw, self.attributes(None, attrs, _attributes)) self.body.append(line) def subgraph(self, graph): """Add the current content of the given graph as subgraph. Args: graph: An instance of the same kind (Graph, Digraph) as the current graph. """ if not isinstance(graph, self.__class__): raise ValueError('%r cannot add subgraphs of different kind: %r ' % (self, graph)) lines = ['\t' + line for line in graph.__iter__(subgraph=True)] self.body.extend(lines) class Graph(Dot): """Graph source code in the DOT language. Args: name: Graph name used in the source code. comment: Comment added to the first line of the source. filename: Filename for saving the source (defaults to name + '.gv'). directory: (Sub)directory for source saving and rendering. format: Rendering output format ('pdf', 'png', ...). engine: Layout command used ('dot', 'neato', ...). encoding: Encoding for saving the source. graph_attr: Mapping of (attribute, value) pairs for the graph. node_attr: Mapping of (attribute, value) pairs set for all nodes. edge_attr: Mapping of (attribute, value) pairs set for all edges. body: Iterable of lines to add to the graph body. strict: Rendering should merge multi-edges (default: False). .. note:: All parameters are optional and can be changed under their corresponding attribute name after instance creation. """ _head = 'graph %s{' _edge = '\t\t%s -- %s%s' _edge_plain = '\t\t%s -- %s' class Digraph(Dot): """Directed graph source code in the DOT language.""" __doc__ += Graph.__doc__.partition('.')[2] _head = 'digraph %s{' _edge = '\t\t%s -> %s%s' _edge_plain = '\t\t%s -> %s' graphviz-0.5.2/graphviz/files.py0000666000000000000000000001541113020607126015357 0ustar rootroot# files.py - save, render, view """Save DOT code objects, render with Graphviz dot, and open in viewer.""" import os import io import codecs from ._compat import text_type from . import backend, tools __all__ = ['File', 'Source'] class Base(object): _format = 'pdf' _engine = 'dot' _encoding = 'utf-8' @property def format(self): """The output format used for rendering ('pdf', 'png', ...).""" return self._format @format.setter def format(self, format): format = format.lower() if format not in backend.FORMATS: raise ValueError('unknown format: %r' % format) self._format = format @property def engine(self): """The layout commmand used for rendering ('dot', 'neato', ...).""" return self._engine @engine.setter def engine(self, engine): engine = engine.lower() if engine not in backend.ENGINES: raise ValueError('unknown engine: %r' % engine) self._engine = engine @property def encoding(self): """The encoding for the saved source file.""" return self._encoding @encoding.setter def encoding(self, encoding): if encoding is not None: codecs.lookup(encoding) self._encoding = encoding class File(Base): directory = '' _default_extension = 'gv' def __init__(self, filename=None, directory=None, format=None, engine=None, encoding=None): if filename is None: name = getattr(self, 'name', None) or self.__class__.__name__ filename = '%s.%s' % (name, self._default_extension) self.filename = filename if directory is not None: self.directory = directory if format is not None: self.format = format if engine is not None: self.engine = engine if encoding is not None: self.encoding = encoding def _repr_svg_(self): return self.pipe(format='svg').decode(self._encoding) def pipe(self, format=None): """Return the source piped through the Graphviz layout command. Args: format: The output format used for rendering ('pdf', 'png', etc.). Returns: Binary (encoded) stdout of the layout command. """ if format is None: format = self._format data = text_type(self.source).encode(self._encoding) outs = backend.pipe(self._engine, format, data) return outs @property def filepath(self): return os.path.join(self.directory, self.filename) def save(self, filename=None, directory=None): """Save the DOT source to file. Args: filename: Filename for saving the source (defaults to name + '.gv') directory: (Sub)directory for source saving and rendering. Returns: The (possibly relative) path of the saved source file. """ if filename is not None: self.filename = filename if directory is not None: self.directory = directory filepath = self.filepath tools.mkdirs(filepath) data = text_type(self.source) with io.open(filepath, 'w', encoding=self.encoding) as fd: fd.write(data) return filepath def render(self, filename=None, directory=None, view=False, cleanup=False): """Save the source to file and render with the Graphviz engine. Args: filename: Filename for saving the source (defaults to name + '.gv') directory: (Sub)directory for source saving and rendering. view: Open the rendered result with the default application. cleanup: Delete the source file after rendering. Returns: The (possibly relative) path of the rendered file. Raises: RuntimeError: If the Graphviz executable is not found. RuntimeError: If viewer opening is requested but not supported. """ filepath = self.save(filename, directory) rendered = backend.render(self._engine, self._format, filepath) if cleanup: os.remove(filepath) if view: self._view(rendered, self._format) return rendered def view(self, filename=None, directory=None, cleanup=False): """Save the source to file, open the rendered result in a viewer. Args: filename: Filename for saving the source (defaults to name + '.gv') directory: (Sub)directory for source saving and rendering. cleanup: Delete the source file after rendering. Returns: The (possibly relative) path of the rendered file. Raises: RuntimeError: If the Graphviz executable is not found. RuntimeError: If opening the viewer is not supported. Short-cut method for calling ``render()`` with ``view=True``. """ return self.render(view=True, filename=filename, directory=directory, cleanup=cleanup) def _view(self, filepath, format): """Start the right viewer based on file format and platform.""" methodnames = [ '_view_%s_%s' % (format, backend.PLATFORM), '_view_%s' % backend.PLATFORM, ] for name in methodnames: view_method = getattr(self, name, None) if view_method is not None: break else: raise RuntimeError('%r has no built-in viewer support for %r ' 'on %r platform' % (self.__class__, format, backend.PLATFORM)) view_method(filepath) _view_darwin = staticmethod(backend.view.darwin) _view_linux = staticmethod(backend.view.linux) _view_windows = staticmethod(backend.view.windows) class Source(File): """Verbatim DOT source code string to be rendered by Graphviz. Args: source: The verbatim DOT source code string. filename: Filename for saving the source (defaults to name + '.gv'). directory: (Sub)directory for source saving and rendering. format: Rendering output format ('pdf', 'png', ...). engine: Layout command used ('dot', 'neato', ...). encoding: Encoding for saving the source. .. note:: All parameters except source are optional and can be changed under their corresponding attribute name after instance creation. """ def __init__(self, source, filename=None, directory=None, format=None, engine=None, encoding=None): super(Source, self).__init__(filename, directory, format, engine, encoding) self.source = source graphviz-0.5.2/graphviz/lang.py0000666000000000000000000000543013020607126015176 0ustar rootroot# lang.py - dot language creation helpers """Quote strings to be valid DOT identifiers, assemble attributes.""" import re from . import tools __all__ = ['quote', 'quote_edge', 'attributes'] # http://www.graphviz.org/doc/info/lang.html ID = re.compile(r'([a-zA-Z_][a-zA-Z0-9_]*|-?(\.\d+|\d+(\.\d*)?))$') KEYWORD = re.compile(r'((node)|(edge)|(graph)|(digraph)|(subgraph)|(strict))$', re.IGNORECASE) HTML_STRING = re.compile(r'<.*?>$', re.DOTALL) COMPASS = re.compile(r'((n)|(ne)|(e)|(se)|(s)|(sw)|(w)|(nw)|(c)|(_))$') def quote(identifier, valid_id=ID.match, dot_keyword=KEYWORD.match, html=HTML_STRING.match): """Return DOT identifier from string, quote if needed. >>> quote('') '""' >>> quote('spam') 'spam' >>> quote('spam spam') '"spam spam"' >>> quote('-4.2') '-4.2' >>> quote('.42') '.42' >>> quote('<spam>') '<spam>' """ if html(identifier): pass elif not valid_id(identifier) or dot_keyword(identifier): return '"%s"' % identifier.replace('"', '\\"') return identifier def quote_edge(identifier): """Return DOT edge statement node_id from string, quote if needed. >>> quote_edge('spam') 'spam' >>> quote_edge('spam spam:eggs eggs') '"spam spam":"eggs eggs"' >>> quote_edge('spam:eggs:s') 'spam:eggs:s' """ node, _, rest = identifier.partition(':') parts = [quote(node)] if rest: port, _, compass = rest.partition(':') parts.append(quote(port)) if compass: parts.append(compass) return ':'.join(parts) def attributes(label=None, kwargs=None, attributes=None, raw=None): """Return assembled DOT attributes string. Sorts kwargs and attributes if they are plain dicts (to avoid unpredictable order from hash randomization in Python 3.3+). >>> attributes() '' >>> attributes('spam spam', kwargs={'eggs':'eggs', 'ham': 'ham ham'}) ' [label="spam spam" eggs=eggs ham="ham ham"]' >>> attributes(kwargs={'spam': None, 'eggs': ''}) ' [eggs=""]' """ if label is None: result = [] else: result = ['label=%s' % quote(label)] if kwargs: items = ['%s=%s' % (quote(k), quote(v)) for k, v in tools.mapping_items(kwargs) if v is not None] result.extend(items) if attributes: if hasattr(attributes, 'items'): attributes = tools.mapping_items(attributes) items = ['%s=%s' % (quote(k), quote(v)) for k, v in attributes if v is not None] result.extend(items) if raw: result.append(raw) if not result: return '' return ' [%s]' % ' '.join(result) graphviz-0.5.2/graphviz/tools.py0000666000000000000000000000217113020607126015414 0ustar rootroot# tools.py import os from . import _compat __all__ = ['attach', 'mkdirs', 'mapping_items'] def attach(object, name): """Return a decorator doing setattr(object, name) with its argument.""" def decorator(func): setattr(object, name, func) return func return decorator def mkdirs(filename, mode=0o777): """Recursively create directories up to the path of filename as needed.""" dirname = os.path.dirname(filename) if not dirname: return _compat.makedirs(dirname, mode=mode, exist_ok=True) def mapping_items(mapping, _iteritems=_compat.iteritems): """Return an iterator over the mapping items, sort if it's a plain dict. >>> list(mapping_items({'spam': 0, 'ham': 1, 'eggs': 2})) [('eggs', 2), ('ham', 1), ('spam', 0)] >>> from collections import OrderedDict # doctest: +SKIP >>> list(mapping_items(OrderedDict(enumerate(['spam', 'ham', 'eggs'])))) # doctest:+SKIP [(0, 'spam'), (1, 'ham'), (2, 'eggs')] """ if type(mapping) is dict: return iter(sorted(_iteritems(mapping))) return _iteritems(mapping) graphviz-0.5.2/graphviz/_compat.py0000666000000000000000000000106313020607126015675 0ustar rootroot# _compat.py - Python 2/3 compatibility import os import sys PY2 = sys.version_info[0] == 2 if PY2: # pragma: no cover text_type = unicode def iteritems(d): return d.iteritems() def makedirs(name, mode=0o777, exist_ok=False): try: os.makedirs(name, mode) except OSError: if not exist_ok or not os.path.isdir(name): raise else: # pragma: no cover text_type = str def iteritems(d): return iter(d.items()) makedirs = os.makedirs graphviz-0.5.2/graphviz/__init__.py0000666000000000000000000000235313020607314016014 0ustar rootroot# graphviz - create dot, save, render, view """Assemble DOT source code and render it with Graphviz. >>> dot = Digraph(comment='The Round Table') >>> dot.node('A', 'King Arthur') >>> dot.node('B', 'Sir Bedevere the Wise') >>> dot.node('L', 'Sir Lancelot the Brave') >>> dot.edges(['AB', 'AL']) >>> dot.edge('B', 'L', constraint='false') >>> print(dot) #doctest: +NORMALIZE_WHITESPACE // The Round Table digraph { A [label="King Arthur"] B [label="Sir Bedevere the Wise"] L [label="Sir Lancelot the Brave"] A -> B A -> L B -> L [constraint=false] } """ from .dot import Graph, Digraph from .files import Source from .backend import render, pipe, view, ENGINES, FORMATS __all__ = [ 'Graph', 'Digraph', 'Source', 'render', 'pipe', 'view', 'ENGINES', 'FORMATS', ] __title__ = 'graphviz' __version__ = '0.5.2' __author__ = 'Sebastian Bank ' __license__ = 'MIT, see LICENSE' __copyright__ = 'Copyright (c) 2013-2016 Sebastian Bank' #: Set of the supported layout commands used for rendering ('dot', 'neato', ...) ENGINES = ENGINES #: Set of the supported output formats for rendering ('pdf', 'png', ...) FORMATS = FORMATS graphviz-0.5.2/graphviz.egg-info/0000755000000000000000000000000013026663155015401 5ustar rootrootgraphviz-0.5.2/graphviz.egg-info/dependency_links.txt0000666000000000000000000000000113020607452021443 0ustar rootroot graphviz-0.5.2/graphviz.egg-info/PKG-INFO0000666000000000000000000001452113020607452016475 0ustar rootrootMetadata-Version: 1.1 Name: graphviz Version: 0.5.2 Summary: Simple Python interface for Graphviz Home-page: http://github.com/xflr6/graphviz Author: Sebastian Bank Author-email: sebastian.bank@uni-leipzig.de License: MIT Description: Graphviz ======== |PyPI version| |License| |Supported Python| |Format| |Downloads| This package facilitates the creation and rendering of graph descriptions in the DOT_ language of the Graphviz_ graph drawing software (repo_) from Python. Create a graph object, assemble the graph by adding nodes and edges, and retrieve its DOT source code string. Save the source code to a file and render it with the Graphviz installation of your system. Use the ``view`` option/method to directly inspect the resulting (PDF, PNG, SVG, etc.) file with its default application. Graphs can also be rendered and displayed within `Jupyter notebooks`_ (a.k.a. `IPython notebooks`_, example_). Links ----- - GitHub: http://github.com/xflr6/graphviz - PyPI: http://pypi.python.org/pypi/graphviz - Documentation: http://graphviz.readthedocs.io - Changelog: http://graphviz.readthedocs.io/en/latest/changelog.html - Issue Tracker: http://github.com/xflr6/graphviz/issues - Download: http://pypi.python.org/pypi/graphviz#downloads Installation ------------ This package runs under Python 2.6, 2.7, and 3.3+, use pip_ to install: .. code:: bash $ pip install graphviz To render the generated DOT source code, you also need to install Graphviz (`download page`_). Make sure that the directory containing the ``dot`` executable is on your systems' path. Quickstart ---------- Create a graph object: .. code:: python >>> from graphviz import Digraph >>> dot = Digraph(comment='The Round Table') >>> dot #doctest: +ELLIPSIS Add nodes and edges: .. code:: python >>> dot.node('A', 'King Arthur') >>> dot.node('B', 'Sir Bedevere the Wise') >>> dot.node('L', 'Sir Lancelot the Brave') >>> dot.edges(['AB', 'AL']) >>> dot.edge('B', 'L', constraint='false') Check the generated source code: .. code:: python >>> print(dot.source) # doctest: +NORMALIZE_WHITESPACE // The Round Table digraph { A [label="King Arthur"] B [label="Sir Bedevere the Wise"] L [label="Sir Lancelot the Brave"] A -> B A -> L B -> L [constraint=false] } Save and render the source code, optionally view the result: .. code:: python >>> dot.render('test-output/round-table.gv', view=True) 'test-output/round-table.gv.pdf' .. image:: https://raw.github.com/xflr6/graphviz/master/docs/round-table.png :align: center See also -------- - pygraphviz_ |--| full-blown interface wrapping the Graphviz C library with SWIG - graphviz-python_ |--| official Python bindings (documentation_) - pydot_ |--| stable pure-Python approach, requires pyparsing License ------- This package is distributed under the `MIT license`_. .. _pip: http://pip.readthedocs.io .. _Graphviz: http://www.graphviz.org .. _repo: http://github.com/ellson/graphviz/ .. _download page: http://www.graphviz.org/Download.php .. _DOT: http://www.graphviz.org/doc/info/lang.html .. _Jupyter notebooks: http://jupyter.org .. _IPython notebooks: http://ipython.org/notebook.html .. _example: http://nbviewer.jupyter.org/github/xflr6/graphviz/blob/master/examples/notebook.ipynb .. _pygraphviz: http://pypi.python.org/pypi/pygraphviz .. _graphviz-python: http://pypi.python.org/pypi/graphviz-python .. _documentation: http://www.graphviz.org/pdf/gv.3python.pdf .. _pydot: http://pypi.python.org/pypi/pydot .. _MIT license: http://opensource.org/licenses/MIT .. |--| unicode:: U+2013 .. |PyPI version| image:: https://img.shields.io/pypi/v/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Latest PyPI Version .. |License| image:: https://img.shields.io/pypi/l/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: License .. |Supported Python| image:: https://img.shields.io/pypi/pyversions/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Supported Python Versions .. |Format| image:: https://img.shields.io/pypi/format/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Format .. |Downloads| image:: https://img.shields.io/pypi/dm/graphviz.svg :target: https://pypi.python.org/pypi/graphviz :alt: Downloads Keywords: graph visualization dot render Platform: any Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Scientific/Engineering :: Visualization graphviz-0.5.2/graphviz.egg-info/SOURCES.txt0000666000000000000000000000173613020607452017270 0ustar rootrootCHANGES LICENSE MANIFEST.in README.rst requirements.txt run-tests.py setup.cfg setup.py docs/api.rst docs/changelog.rst docs/conf.py docs/examples.rst docs/index.rst docs/license.rst docs/manual.rst docs/pet-shop.png docs/requirements.txt docs/round-table.png docs/_static/cluster.svg docs/_static/er.svg docs/_static/fsm.svg docs/_static/hello.svg docs/_static/holy-grenade.svg docs/_static/pet-shop.svg docs/_static/process.svg docs/_static/round-table.svg docs/_static/structs.svg docs/_static/unix.svg examples/cluster.py examples/er.py examples/fsm.py examples/hello.py examples/notebook.ipynb examples/process.py examples/structs.py examples/unix.py graphviz/__init__.py graphviz/_compat.py graphviz/backend.py graphviz/dot.py graphviz/files.py graphviz/lang.py graphviz/tools.py graphviz.egg-info/PKG-INFO graphviz.egg-info/SOURCES.txt graphviz.egg-info/dependency_links.txt graphviz.egg-info/top_level.txt tests/test_dot.py tests/test_files.py tests/test_lang.py tests/test_tools.pygraphviz-0.5.2/graphviz.egg-info/top_level.txt0000666000000000000000000000001113020607452020117 0ustar rootrootgraphviz graphviz-0.5.2/tests/0000755000000000000000000000000013026663155013217 5ustar rootrootgraphviz-0.5.2/tests/test_dot.py0000666000000000000000000000716213020607126015416 0ustar rootroot# test_dot.py import unittest2 as unittest from graphviz.dot import Graph, Digraph class TestDot(unittest.TestCase): def test_repr_svg(self): self.assertRegexpMatches(Graph('spam')._repr_svg_(), r'(?s)^<\?xml .+\s*$') def test_attr(self): with self.assertRaises(ValueError): Graph().attr('spam') def test_strict(self): self.assertEqual(Graph(strict=True).source, 'strict graph {\n}') self.assertEqual(Digraph(strict=True).source, 'strict digraph {\n}') def test_subgraph_invalid(self): with self.assertRaises(ValueError): Graph().subgraph(Digraph()) with self.assertRaises(ValueError): Digraph().subgraph(Graph()) def test_subgraph_recursive(self): # guard against potential infinite loop dot = Graph() dot.subgraph(dot) self.assertEqual(dot.source, 'graph {\n\tsubgraph {\n\t}\n}') def test_subgraph(self): s1 = Graph() s1.node('A') s1.node('B') s1.node('C') s1.edge('A', 'B', constraint='false') s1.edges(['AC', 'BC']) s2 = Graph() s2.node('D') s2.node('E') s2.node('F') s2.edge('D', 'E', constraint='false') s2.edges(['DF', 'EF']) dot = Graph() dot.subgraph(s1) dot.subgraph(s2) dot.attr('edge', style='dashed') dot.edges(['AD', 'BE', 'CF']) self.assertEqual(dot.source, '''graph { subgraph { A B C A -- B [constraint=false] A -- C B -- C } subgraph { D E F D -- E [constraint=false] D -- F E -- F } edge [style=dashed] A -- D B -- E C -- F }''') class TestHTML(unittest.TestCase): """http://www.graphviz.org/doc/info/shapes.html#html""" def test_label_html(self): dot = Digraph('structs', node_attr={'shape': 'plaintext'}) dot.node('struct1', '''<
left middle right
>''') dot.node('struct2', '''<
one two
>''') dot.node('struct3', '''<
hello
world
b g h
c d e
f
>''') dot.edge('struct1:f1', 'struct2:f0') dot.edge('struct1:f2', 'struct3:here') self.assertEqual(dot.source, '''digraph structs { node [shape=plaintext] struct1 [label=<
left middle right
>] struct2 [label=<
one two
>] struct3 [label=<
hello
world
b g h
c d e
f
>] struct1:f1 -> struct2:f0 struct1:f2 -> struct3:here }''') dot.render('test-output/html.gv') graphviz-0.5.2/tests/test_files.py0000666000000000000000000000332613020607126015730 0ustar rootroot# test_files.py import os import unittest2 as unittest from graphviz.files import File, Source class TestBase(unittest.TestCase): def setUp(self): self.file = File() def test_format(self): with self.assertRaisesRegexp(ValueError, 'format'): self.file.format = 'spam' def test_engine(self): with self.assertRaisesRegexp(ValueError, 'engine'): self.file.engine = 'spam' def test_encoding(self): with self.assertRaisesRegexp(LookupError, 'encoding'): self.file.encoding = 'spam' class TestFile(unittest.TestCase): def test_init(self): f = File('name', 'dir', 'PNG', 'NEATO', 'latin1') self.assertEqual(f.filename, 'name') self.assertEqual(f.format, 'png') self.assertEqual(f.engine, 'neato') self.assertEqual(f.encoding, 'latin1') class TestNoent(unittest.TestCase): def setUp(self): self._oldpath = os.environ.get('PATH') os.environ['PATH'] = '' self.file = File('spam.gv', 'test-output') self.file.source = 'spam' def tearDown(self): if self._oldpath is None: del os.environ['PATH'] else: os.environ['PATH'] = self._oldpath def test_pipe(self): with self.assertRaisesRegexp(RuntimeError, 'failed to execute'): self.file.pipe() def test_render(self): with self.assertRaisesRegexp(RuntimeError, 'failed to execute'): self.file.render() class TestSource(unittest.TestCase): def test_init(self): source = 'graph { hello -> world }' s = Source(source) self.assertEqual(s.source, source) graphviz-0.5.2/tests/test_lang.py0000666000000000000000000000152413020607126015545 0ustar rootroot# test_lang.py import unittest2 as unittest from graphviz.lang import quote, attributes class TestQuote(unittest.TestCase): def test_quote_quotes(self): self.assertEqual(quote('"spam"'), r'"\"spam\""') def test_quote_keyword(self): self.assertEqual(quote('node'), '"node"') self.assertEqual(quote('EDGE'), '"EDGE"') self.assertEqual(quote('Graph'), '"Graph"') class TestAttributes(unittest.TestCase): def test_attributes_pairs(self): self.assertEqual(attributes(attributes=[('spam', 'eggs')]), ' [spam=eggs]') def test_attributes_map(self): self.assertEqual(attributes(attributes={'spam': 'eggs'}), ' [spam=eggs]') def test_attributes_raw(self): self.assertEqual(attributes(raw='spam'), ' [spam]') graphviz-0.5.2/tests/test_tools.py0000666000000000000000000000101413020607126015756 0ustar rootroot# test_tools.py import unittest2 as unittest import os from graphviz.tools import mkdirs class TestMkdirs(unittest.TestCase): @staticmethod def _dirnames(path=os.curdir): return [name for name in os.listdir(path) if os.path.isdir(name)] def test_cwd(self): dirnames = self._dirnames() mkdirs('setup.py') self.assertEqual(self._dirnames(), dirnames) def test_file(self): with self.assertRaises(OSError): mkdirs('setup.py/spam')