# HG changeset patch # User Jeff Hammel # Date 1421962436 28800 # Node ID e3c3ee7b5ccf77b521077e3394de3fa0395652b6 # Parent 3781174542bbb8a336c5d3c673035f3c7254e471 stubbing manipulate data diff -r 3781174542bb -r e3c3ee7b5ccf numerics/convert.py --- a/numerics/convert.py Tue Jan 20 16:50:42 2015 -0800 +++ b/numerics/convert.py Thu Jan 22 13:33:56 2015 -0800 @@ -48,7 +48,8 @@ cast a column of data """ column_types = [column_type(column) for column in columns] - raise NotImplementedError('TODO') # -> record TODO items + return [[column_type(row) for row in column] + for column_type, column in zip(column_types, columns)] def main(args=sys.argv[1:]): diff -r 3781174542bb -r e3c3ee7b5ccf numerics/manipulate.py --- a/numerics/manipulate.py Tue Jan 20 16:50:42 2015 -0800 +++ b/numerics/manipulate.py Thu Jan 22 13:33:56 2015 -0800 @@ -8,30 +8,28 @@ # imports import argparse import os -import subprocess import sys +from .convert import cast_columns +from .read import CSVParser # module globals -__all__ = ['main', 'Parser'] +__all__ = ['main', 'ManipulationParser'] here = os.path.dirname(os.path.realpath(__file__)) string = (str, unicode) -class Parser(argparse.ArgumentParser): - """CLI option parser""" +class ManipulationParser(CSVParser): + """CLI option parser for data manipulation""" + def __init__(self, **kwargs): - kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter) kwargs.setdefault('description', __doc__) - argparse.ArgumentParser.__init__(self, **kwargs) + CSVParser.__init__(self, **kwargs) + self.add_argument('--list', '--entries', '--list-entries', + dest='list_entries', nargs='?', const=0, type=int, + help="list all entries for this column") 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 typed_data(self): + raise NotImplementedError('TODO') # -> record TODO items def main(args=sys.argv[1:]): """CLI""" @@ -40,6 +38,9 @@ parser = Parser() options = parser.parse_args(args) + if options.list_entries: + raise NotImplementedError('TODO') # -> record TODO items + if __name__ == '__main__': main()