# HG changeset patch # User Jeff Hammel # Date 1411263908 25200 # Node ID 9e593b26e93b645afc94b86c624bef11f2501427 # Parent 90edb741397d31db6f6d0211e80989b98f44a0ca add script to plot data diff -r 90edb741397d -r 9e593b26e93b numerics/plot.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/numerics/plot.py Sat Sep 20 18:45:08 2014 -0700 @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +plot data +""" + +# imports +import argparse +import os +import subprocess +import sys + +# module globals +__all__ = ['main', 'Parser'] +here = os.path.dirname(os.path.realpath(__file__)) +string = (str, unicode) + +def ensure_dir(directory): + """ensure a directory exists""" + if os.path.exists(directory): + assert os.path.isdir(directory) + return directory + os.makedirs(directory) + return directory + + +class Parser(argparse.ArgumentParser): + """CLI option parser""" + def __init__(self, **kwargs): + kwargs.setdefault('description', __doc__) + argparse.ArgumentParser.__init__(self, **kwargs) + self.options = None + + def parse_args(self, *args, **kw): + options = argparse.ArgumentParser.parse_args(self, *args, **kw) + self.validate(options) + self.options = options + return options + + def validate(self, options): + """validate options""" + +def main(args=sys.argv[1:]): + """CLI""" + + # parse command line options + parser = Parser() + options = parser.parse_args(args) + +if __name__ == '__main__': + main() +