def main():
global formats<EOL>test_dir = os.path.dirname(os.path.abspath(__file__))<EOL>optparser = optparse.OptionParser(<EOL>usage="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>', metavar='<STR_LIT>',<EOL>type="<STR_LIT:string>", dest="<STR_LIT>", default=sys.executable,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>', metavar='<STR_LIT>',<EOL>type="<STR_LIT:string>", dest="<STR_LIT>", default=os.path.join(test_dir, os.path.pardir, '<STR_LIT>'),<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>action="<STR_LIT:store_true>",<EOL>dest="<STR_LIT>", default=False,<EOL>help="<STR_LIT>")<EOL>(options, args) = optparser.parse_args(sys.argv[<NUM_LIT:1>:])<EOL>if len(args):<EOL><INDENT>formats = args<EOL><DEDENT>for format in formats:<EOL><INDENT>test_subdir = os.path.join(test_dir, format)<EOL>for filename in os.listdir(test_subdir):<EOL><INDENT>name, ext = os.path.splitext(filename)<EOL>if ext == '<STR_LIT:.>' + format:<EOL><INDENT>sys.stdout.write(filename + '<STR_LIT:\n>')<EOL>profile = os.path.join(test_subdir, filename)<EOL>dot = os.path.join(test_subdir, name + '<STR_LIT>')<EOL>png = os.path.join(test_subdir, name + '<STR_LIT>')<EOL>ref_dot = os.path.join(test_subdir, name + '<STR_LIT>')<EOL>ref_png = os.path.join(test_subdir, name + '<STR_LIT>')<EOL>if run([ options.python, options.gprof2dot, '<STR_LIT>', format, '<STR_LIT>', dot, profile]) != <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>if run(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', png, dot]) != <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>if options.force or not os.path.exists(ref_dot):<EOL><INDENT>shutil.copy(dot, ref_dot)<EOL>shutil.copy(png, ref_png)<EOL><DEDENT>else:<EOL><INDENT>diff(ref_dot, dot)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Main program.