#NEWLINE# def write_dot_graph( self , obj ) : #NEWLINE# #INDENT# if ( self . out_file is None ) : #NEWLINE# #INDENT# raise Exception ( 'Please assign an output filename to "out_file"' ) #NEWLINE# #UNINDENT# context = DotContext ( max_depth = self . max_depth , max_width = self . max_width ) #NEWLINE# obj . announce_to ( context ) #NEWLINE# source = 'digraph G {{\n\tranksep=equally;\n{}}}\n' . format ( context . get ( ) ) #NEWLINE# ( filedesc , tmpname ) = tempfile . mkstemp ( ) #NEWLINE# with os . fdopen ( filedesc , 'w' ) as handle : #NEWLINE# #INDENT# handle . write ( source ) #NEWLINE# #UNINDENT# cmd = self . executableCommand ( tmpname ) #NEWLINE# ret = subprocess . call ( cmd ) #NEWLINE# if self . out_dot : #NEWLINE# #INDENT# os . rename ( tmpname , self . out_dot ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# os . unlink ( tmpname ) #NEWLINE# #UNINDENT# if ( ret > 0 ) : #NEWLINE# #INDENT# raise Exception ( 'Failed executing: "{}"' . format ( ' ' . join ( cmd ) ) )