DISPLAY_COMMAND_FORMAT is the default command-line for displaying a DOT file, where %s is replaced with the name of the file to display
Bases: object
Mix-in baseclass for displaying a DOT rendering of an object.
Uses the object’s :meth`dot_iter` method to display a DOT rendering of the object.
Display a dot-generated representation of the graph.
Optional dot_iter is the generator function to pull on for text lines of DOT code. It is called with kwargs. It defaults to the object’s dot_iter method
Optional temp_file_prefix is the prefix used for the temporary filename. It defaults to the name of the type of self.
Optional display_command_format is a formatting string, with %s where the temporary filename goes, that is used to generate the command that will display the file. It defaults to the the value of the module’s DISPLAY_COMMAND_FORMAT attribute.
Remaining keyword arguments, kwargs, are handed to the dot_iter generator function. In general, no arguments are necessary to get an object to display.
Returns a tuple of four items: (temp_filename, stdout, stderr, cmd), where temp_filename is the name of the temporary file that gets created for the display command to use, stdout and stderr are the standard-out and standard-error from the command, and cmd is a string representing the command. The caller is responsible for removing temp_filename.
Raises AttributeError if dot_iter is not given and the object doesn’t have a dot_iter method
Raises SubprocessError if the command fails to execute or if the command exits with a non-zero return code.
Function for testing DotDisplay functionality.
>>> obj = test_DotDisplay()
>>> temp_filename, stdout, stderr, cmd = obj.dot_display(display_command_format="cat %s")
>>> temp_filename
'/tmp/TestDotDisplay_....dot'
>>> cmd
'cat /tmp/TestDotDisplay_....dot'
>>> stdout
'digraph { \n n00 [label="node_00"]; \n n01 [label="node_01"]; \n n00 -> n01; \n} \n'
>>> stderr
''
>>> os.remove(temp_filename)