def main():
global totalMethod<EOL>formatNames = list(formats.keys())<EOL>formatNames.sort()<EOL>themeNames = list(themes.keys())<EOL>themeNames.sort()<EOL>labelNames = list(labels.keys())<EOL>labelNames.sort()<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>",<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>', metavar='<STR_LIT>',<EOL>type="<STR_LIT:float>", dest="<STR_LIT>", default=<NUM_LIT:0.5>,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>', metavar='<STR_LIT>',<EOL>type="<STR_LIT:float>", dest="<STR_LIT>", default=<NUM_LIT:0.1>,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>type="<STR_LIT>", choices=formatNames,<EOL>dest="<STR_LIT>", default="<STR_LIT>",<EOL>help="<STR_LIT>" % naturalJoin(formatNames))<EOL>optparser.add_option(<EOL>'<STR_LIT>',<EOL>type="<STR_LIT>", choices=('<STR_LIT>', '<STR_LIT>'),<EOL>dest="<STR_LIT>", default=totalMethod,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT:-c>', '<STR_LIT>',<EOL>type="<STR_LIT>", choices=themeNames,<EOL>dest="<STR_LIT>", default="<STR_LIT>",<EOL>help="<STR_LIT>" % naturalJoin(themeNames))<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>optparser.add_option(<EOL>'<STR_LIT>',<EOL>action="<STR_LIT:store_true>",<EOL>dest="<STR_LIT>", default=False,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>',<EOL>action="<STR_LIT:store_true>",<EOL>dest="<STR_LIT>",<EOL>help=optparse.SUPPRESS_HELP)<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>optparser.add_option(<EOL>'<STR_LIT>',<EOL>action="<STR_LIT:store_true>",<EOL>dest="<STR_LIT>", default=False,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', metavar='<STR_LIT>',<EOL>type='<STR_LIT>', choices=labelNames,<EOL>action='<STR_LIT>',<EOL>dest='<STR_LIT>',<EOL>help="<STR_LIT>" % (<EOL>naturalJoin(labelNames), '<STR_LIT:U+002CU+0020>'.join(defaultLabelNames)))<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>type="<STR_LIT:string>",<EOL>dest="<STR_LIT:root>", default="<STR_LIT>",<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>type="<STR_LIT:string>",<EOL>dest="<STR_LIT>", default="<STR_LIT>",<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>',<EOL>type="<STR_LIT:int>",<EOL>dest="<STR_LIT>", default=-<NUM_LIT:1>,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>',<EOL>type="<STR_LIT:float>", dest="<STR_LIT>", default=<NUM_LIT:1.0>,<EOL>help="<STR_LIT>")<EOL>optparser.add_option(<EOL>'<STR_LIT>', '<STR_LIT>', action="<STR_LIT>",<EOL>type="<STR_LIT:string>", dest="<STR_LIT>",<EOL>help="<STR_LIT>")<EOL>(options, args) = optparser.parse_args(sys.argv[<NUM_LIT:1>:])<EOL>if len(args) > <NUM_LIT:1> and options.format != '<STR_LIT>':<EOL><INDENT>optparser.error('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>theme = themes[options.theme]<EOL><DEDENT>except KeyError:<EOL><INDENT>optparser.error('<STR_LIT>' % options.theme)<EOL><DEDENT>if options.theme_skew:<EOL><INDENT>theme.skew = options.theme_skew<EOL><DEDENT>totalMethod = options.totalMethod<EOL>try:<EOL><INDENT>Format = formats[options.format]<EOL><DEDENT>except KeyError:<EOL><INDENT>optparser.error('<STR_LIT>' % options.format)<EOL><DEDENT>if Format.stdinInput:<EOL><INDENT>if not args:<EOL><INDENT>fp = sys.stdin<EOL><DEDENT>elif PYTHON_3:<EOL><INDENT>fp = open(args[<NUM_LIT:0>], '<STR_LIT>', encoding='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>fp = open(args[<NUM_LIT:0>], '<STR_LIT>')<EOL><DEDENT>parser = Format(fp)<EOL><DEDENT>elif Format.multipleInput:<EOL><INDENT>if not args:<EOL><INDENT>optparser.error('<STR_LIT>' % options.format)<EOL><DEDENT>parser = Format(*args)<EOL><DEDENT>else:<EOL><INDENT>if len(args) != <NUM_LIT:1>:<EOL><INDENT>optparser.error('<STR_LIT>' % options.format)<EOL><DEDENT>parser = Format(args[<NUM_LIT:0>])<EOL><DEDENT>profile = parser.parse()<EOL>if options.output is None:<EOL><INDENT>if PYTHON_3:<EOL><INDENT>output = open(sys.stdout.fileno(), mode='<STR_LIT>', encoding='<STR_LIT>', closefd=False)<EOL><DEDENT>else:<EOL><INDENT>output = sys.stdout<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if PYTHON_3:<EOL><INDENT>output = open(options.output, '<STR_LIT>', encoding='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>output = open(options.output, '<STR_LIT>')<EOL><DEDENT><DEDENT>dot = DotWriter(output)<EOL>dot.strip = options.strip<EOL>dot.wrap = options.wrap<EOL>labelNames = options.node_labels or defaultLabelNames<EOL>dot.show_function_events = [labels[l] for l in labelNames]<EOL>if options.show_samples:<EOL><INDENT>dot.show_function_events.append(SAMPLES)<EOL><DEDENT>profile = profile<EOL>profile.prune(options.node_thres/<NUM_LIT>, options.edge_thres/<NUM_LIT>, options.filter_paths, options.color_nodes_by_selftime)<EOL>if options.root:<EOL><INDENT>rootIds = profile.getFunctionIds(options.root)<EOL>if not rootIds:<EOL><INDENT>sys.stderr.write('<STR_LIT>' + options.root + '<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>profile.prune_root(rootIds, options.depth)<EOL><DEDENT>if options.leaf:<EOL><INDENT>leafIds = profile.getFunctionIds(options.leaf)<EOL>if not leafIds:<EOL><INDENT>sys.stderr.write('<STR_LIT>' + options.leaf + '<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>profile.prune_leaf(leafIds, options.depth)<EOL><DEDENT>dot.graph(profile, theme)<EOL>
Main program.