From 5172bd4525740e440f5675cbd7b05a962a97238d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 25 Oct 2010 09:55:25 -0400 Subject: [PATCH] Move main src/sorting/scaling.py code into main() function. --- src/sorting/scaling.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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() -- 2.26.2