Skip to content

Commit

Permalink
Stop using graphviz's private FORMATS set.
Browse files Browse the repository at this point in the history
The argument parser uses it to fail early when given an unsupported
image format.  Since the graphviz library itself determines what image
formats it supports, the contents of the set isn't private, but its
location inside the graphviz Python package is.

This commit copies the set into _visualize to break the dependency on
this private API.
  • Loading branch information
markrwilliams committed Nov 19, 2016
1 parent 3ffbac9 commit ef0a714
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion automat/_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,46 @@
from ._discover import findMachines


FORMATS = frozenset([ # 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',
])


def _gvquote(s):
return '"{}"'.format(s.replace('"', r'\"'))

Expand Down Expand Up @@ -143,7 +183,7 @@ def tool(_progname=sys.argv[0],
default=".automat_visualize")
argumentParser.add_argument('--image-type', '-t',
help="The image format.",
choices=graphviz.files.FORMATS,
choices=FORMATS,
default='png')
argumentParser.add_argument('--view', '-v',
help="View rendered graphs with"
Expand Down

0 comments on commit ef0a714

Please sign in to comment.