def create(self, prog=None, format='<STR_LIT>'):
if prog is None:<EOL><INDENT>prog = self.prog<EOL><DEDENT>if isinstance(prog, (list, tuple)):<EOL><INDENT>prog, args = prog[<NUM_LIT:0>], prog[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>args = []<EOL><DEDENT>if self.progs is None:<EOL><INDENT>self.progs = find_graphviz()<EOL>if self.progs is None:<EOL><INDENT>raise InvocationException(<EOL>'<STR_LIT>' )<EOL><DEDENT><DEDENT>if prog not in self.progs:<EOL><INDENT>raise InvocationException(<EOL>'<STR_LIT>' % prog )<EOL><DEDENT>if not os.path.exists( self.progs[prog] ) or not os.path.isfile( self.progs[prog] ):<EOL><INDENT>raise InvocationException(<EOL>'<STR_LIT>' % self.progs[prog] )<EOL><DEDENT>tmp_fd, tmp_name = tempfile.mkstemp()<EOL>os.close(tmp_fd)<EOL>self.write(tmp_name)<EOL>tmp_dir = os.path.dirname(tmp_name )<EOL>for img in self.shape_files:<EOL><INDENT>f = file(img, '<STR_LIT:rb>')<EOL>f_data = f.read()<EOL>f.close()<EOL>f = file( os.path.join( tmp_dir, os.path.basename(img) ), '<STR_LIT:wb>' )<EOL>f.write(f_data)<EOL>f.close()<EOL><DEDENT>cmdline = [self.progs[prog], '<STR_LIT>'+format, tmp_name] + args<EOL>p = subprocess.Popen(<EOL>cmdline,<EOL>cwd=tmp_dir,<EOL>stderr=subprocess.PIPE, stdout=subprocess.PIPE)<EOL>stderr = p.stderr<EOL>stdout = p.stdout<EOL>stdout_output = list()<EOL>while True:<EOL><INDENT>data = stdout.read()<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>stdout_output.append(data)<EOL><DEDENT>stdout.close()<EOL>stdout_output = '<STR_LIT>'.join(stdout_output)<EOL>if not stderr.closed:<EOL><INDENT>stderr_output = list()<EOL>while True:<EOL><INDENT>data = stderr.read()<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>stderr_output.append(data)<EOL><DEDENT>stderr.close()<EOL>if stderr_output:<EOL><INDENT>stderr_output = '<STR_LIT>'.join(stderr_output)<EOL><DEDENT><DEDENT>status = p.wait()<EOL>if status != <NUM_LIT:0> :<EOL><INDENT>raise InvocationException(<EOL>'<STR_LIT>' % (<EOL>status, stderr_output) )<EOL><DEDENT>elif stderr_output:<EOL><INDENT>print(stderr_output)<EOL><DEDENT>for img in self.shape_files:<EOL><INDENT>os.unlink( os.path.join( tmp_dir, os.path.basename(img) ) )<EOL><DEDENT>os.unlink(tmp_name)<EOL>return stdout_output<EOL>
Creates and returns a Postscript representation of the graph.

        create will write the graph to a temporary dot file and process
        it with the program given by 'prog' (which defaults to 'twopi'),
        reading the Postscript output and returning it as a string is the
        operation is successful.
        On failure None is returned.

        There's also the preferred possibility of using:

            create_'format'(prog='program')

        which are automatically defined for all the supported formats.
        [create_ps(), create_gif(), create_dia(), ...]

        If 'prog' is a list instead of a string the fist item is expected
        to be the program name, followed by any optional command-line
        arguments for it:

            [ 'twopi', '-Tdot', '-s10' ]