From: W. Trevor King Date: Mon, 25 Oct 2010 13:55:25 +0000 (-0400) Subject: Move main src/sorting/scaling.py code into main() function. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5172bd4525740e440f5675cbd7b05a962a97238d;p=parallel_computing.git Move main src/sorting/scaling.py code into main() function. --- diff --git a/src/sorting/scaling.py b/src/sorting/scaling.py index 5af9a8c..c553ee4 100755 --- a/src/sorting/scaling.py +++ b/src/sorting/scaling.py @@ -65,11 +65,13 @@ def run_tests(executable, stdin=True, data_file=None, ordered=False, N *= 2 return times - -if __name__ == '__main__': +def main(argv=None): import optparse import tempfile + if argv == None: + argv = sys.argv[1:] + p = optparse.OptionParser( usage='%prog [options] executable', epilog=__doc__) p.add_option('-s', '--stdin', dest='stdin', default=False, @@ -81,7 +83,7 @@ if __name__ == '__main__': p.add_option('-p', '--plot', dest='plot', default=None, help='Filename for a scaling plot (no plot is generated if this option is not set).') - options,args = p.parse_args() + options,args = p.parse_args(argv) executable = args[0] @@ -135,3 +137,6 @@ if __name__ == '__main__': a.set_ylabel('t (s)') a.legend(loc='best') f.savefig(options.plot) + +if __name__ == '__main__': + main()