view numerics/plot.py @ 19:276beb743a59

stub
author Jeff Hammel <k0scist@gmail.com>
date Sun, 21 Sep 2014 20:13:17 -0700
parents e3fc1f75241d
children cd9ec2784077
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
plot data

Usage::

  plot foo.csv

Generates plots of all columns of foo versus the first column.
The title is foo.csv unless overridden with ``--title``.
"""

# imports
import argparse
import os
import sys

# module globals
__all__ = ['main', 'PlotParser']
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 PlotParser(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 = PlotParser()
    options = parser.parse_args(args)


if __name__ == '__main__':
    main()