changeset 124:84baf80a5202

stubbing massive deletion of code (okay not that massive)
author Jeff Hammel <k0scist@gmail.com>
date Mon, 16 Mar 2015 19:17:46 -0700
parents 067705f465e8
children d255058333b2
files numerics/mean.py numerics/reduce.py
diffstat 2 files changed, 69 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/mean.py	Mon Mar 16 18:50:40 2015 -0700
+++ b/numerics/mean.py	Mon Mar 16 19:17:46 2015 -0700
@@ -6,11 +6,7 @@
 """
 
 # imports
-import argparse
-import csv
-import os
 import sys
-from .data import transpose
 from .filters import mean
 from .manipulate import ManipulationParser
 from .write import CSVWriter
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/numerics/reduce.py	Mon Mar 16 19:17:46 2015 -0700
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+reduce a vector to a scalar
+"""
+
+# imports
+import argparse
+import os
+import subprocess
+import sys
+import time
+
+# 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
+
+
+class Parser(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()
+
+