changeset 125:d255058333b2

putzing
author Jeff Hammel <k0scist@gmail.com>
date Mon, 16 Mar 2015 19:31:49 -0700
parents 84baf80a5202
children 575c8e44227c
files numerics/manipulate.py numerics/mean.py numerics/reduce.py
diffstat 3 files changed, 15 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/manipulate.py	Mon Mar 16 19:17:46 2015 -0700
+++ b/numerics/manipulate.py	Mon Mar 16 19:31:49 2015 -0700
@@ -14,7 +14,7 @@
 from .read import CSVParser
 
 # module globals
-__all__ = ['ManipulationParser', 'main']
+__all__ = ['ManipulationParser', 'FloatParser', 'main']
 
 
 class ManipulationParser(CSVParser):
@@ -35,6 +35,11 @@
         return transpose(self.typed_data())
 
 
+class FloatParser(ManipulationParser):
+    """manipulation parser convenience just for floats"""
+    types = (float,)
+
+
 def main(args=sys.argv[1:]):
     """CLI"""
 
--- a/numerics/mean.py	Mon Mar 16 19:17:46 2015 -0700
+++ b/numerics/mean.py	Mon Mar 16 19:31:49 2015 -0700
@@ -8,16 +8,17 @@
 # imports
 import sys
 from .filters import mean
-from .manipulate import ManipulationParser
+from .manipulate import FloatParser
 from .write import CSVWriter
 
+__all__ = ['main']
+
 
 def main(args=sys.argv[1:]):
     """CLI"""
 
     # parse command line options
-    parser = ManipulationParser()
-    parser.types = (float,)
+    parser = FloatParser()
     options = parser.parse_args(args)
 
     # read data
--- a/numerics/reduce.py	Mon Mar 16 19:17:46 2015 -0700
+++ b/numerics/reduce.py	Mon Mar 16 19:31:49 2015 -0700
@@ -6,64 +6,22 @@
 """
 
 # imports
-import argparse
-import os
-import subprocess
 import sys
-import time
+from .filters import mean
+from .manipulate import FloatParser
+from .write import CSVWriter
 
 # 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):
-        if not os.path.isdir(directory):
-            raise OSError("Not a directory: '{}'".format(directory))
-        return directory
-    os.makedirs(directory)
-    return directory
+__all__ = ['ReduceParser']
 
 
-class Parser(argparse.ArgumentParser):
+class ReduceParser(argparse.ArgumentParser):
     """CLI option parser"""
     def __init__(self, **kwargs):
         kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)
         kwargs.setdefault('description', __doc__)
         argparse.ArgumentParser.__init__(self, **kwargs)
-        self.add_argument('--monitor', dest='monitor',
-                          type=float, metavar='SLEEP',
-                          help="run in monitor mode")
         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)
-
-    try:
-        while True:
-            if options.monitor:
-                time.sleep(options.monitor)
-            else:
-                break
-    except KeyboardInterrupt:
-        pass
-
-if __name__ == '__main__':
-    main()