From ef0a714037fd1dea4c8a6011855b2fbff7f30eb7 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Sat, 19 Nov 2016 12:44:30 -0800 Subject: [PATCH] Stop using graphviz's private FORMATS set. 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. --- automat/_visualize.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/automat/_visualize.py b/automat/_visualize.py index 05c020b..9468667 100644 --- a/automat/_visualize.py +++ b/automat/_visualize.py @@ -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'\"')) @@ -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"