changeset 699:72d2a2e09c6a

stub: slicing
author Jeff Hammel <k0scist@gmail.com>
date Tue, 12 Aug 2014 16:49:58 -0700
parents 3481ac810b60
children 2a3323626bcf
files python/slice.py
diffstat 1 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/slice.py	Tue Aug 12 16:49:58 2014 -0700
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+slice a arbitrarily sized list
+"""
+
+# imports
+import argparse
+import os
+import subprocess
+import sys
+
+# module globals
+__all__ = ['main', 'Parser']
+
+def slice(container, n_chunks):
+    size = int(len(container)/n_chunks)
+    
+
+class Parser(argparse.ArgumentParser):
+    """CLI option parser"""
+    def __init__(self, **kwargs):
+        kwargs.setdefault('description', __doc__)
+        argparse.ArgumentParser.__init__(self, **kwargs)
+        self.add_argument('N', type=int,
+                          help="number of chunks")
+        self.add_argument('-M', '--len', dest='length', type=int,
+                          help="length of list")
+        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)
+
+if __name__ == '__main__':
+    main()
+