def main(argv=None):
    from optparse import OptionParser

    if argv is None:
        argv = sys.argv[1:]

    usage = "python -m peek [-o output_file_path] scriptfile [arg] ..."
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-o', '--output', dest="output",
        help="Save stats to <outfile> directory", default=None)

    if not argv:
        parser.print_usage()
        sys.exit(2)

    (options, args) = parser.parse_args()
    sys.argv[:] = args

    if len(args) > 0:
        progname = args[0]
        sys.path.insert(0, os.path.dirname(progname))

        from peek.collector import Collector
        from peek.reporter import HTMLReporter

        collector = Collector(log=(not options.output))
        collector.start()

        try:
            run_python_file(progname, args)
        finally:
            collector.stop()

            reporter = HTMLReporter(progname, collector, output=options.output)
            reporter.report()

    else:
        parser.print_usage()
dataset/ETHPy150Open dcramer/peek/peek/runner.py/main/original