changeset 152:abfd4c294f02

subclass ManipulationParser
author Jeff Hammel <k0scist@gmail.com>
date Mon, 13 Apr 2015 10:35:37 -0700
parents 1d24392ba5f5
children 0e26d3d54329
files numerics/cleanse.py
diffstat 1 files changed, 5 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/cleanse.py	Mon Apr 13 10:32:22 2015 -0700
+++ b/numerics/cleanse.py	Mon Apr 13 10:35:37 2015 -0700
@@ -10,46 +10,26 @@
 import os
 import sys
 import time
+from .manipulate import ManipulationParser
 
 # module globals
 __all__ = ['main', 'CleanseParser']
 
 
-class CleanseParser(argparse.ArgumentParser):
+class CleanseParser(ManipulationParser):
     """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
+        ManipulationParser.__init__(self, **kwargs)
 
-    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()
+    parser = CleanseParser()
     options = parser.parse_args(args)
 
-    try:
-        while True:
-            if options.monitor:
-                time.sleep(options.monitor)
-            else:
-                break
-    except KeyboardInterrupt:
-        pass
+
 
 if __name__ == '__main__':
     main()