changeset 721:2ebf5cef55de

move to k0s.org/hg/configuration
author Jeff Hammel <k0scist@gmail.com>
date Tue, 04 Nov 2014 15:09:33 -0800
parents f136912c81a9
children be9f792abaad
files python/dictarg.py
diffstat 1 files changed, 0 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/python/dictarg.py	Tue Nov 04 15:06:59 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-
-import sys
-
-def dictarg(adict, argv=sys.argv[1:]):
-
-    shopts = {}
-    
-    # build list of keys
-    for i in adict.keys():
-        for j in i:
-            s = str(j)
-            if len(s) == 1:
-                if shopts.has_key(s):
-                    continue
-                shopts[s] = i
-                break
-        else:
-            print >> sys.stderr, "dictarg: couldn't generate key for '%s'" % i
-            sys.exit(1)
-
-    optstring = "?"
-    for i in shopts.keys():
-        optstring += i + ':' # all these options should have arguments
-    
-    # look for command line args
-    import getopt
-
-    opts, args = getopt.getopt(argv, optstring)
-
-    if ('-?', '') in opts:
-        print 'Options:'
-        for i in shopts:
-            print '-%s %s [%s]' % (i, shopts[i], adict[shopts[i]])
-        sys.exit(0)
-        
-    for o, v in opts:
-        o = o[1:] # cut off the dash
-        adict[shopts[o]] = v
-
-# test if invoked from command line
-if __name__ == '__main__':
-    adict = {}
-    for i in sys.argv:
-        adict[i] = len(i)
-
-    # print the help
-    dictarg(adict, ['-?'])
-
-    # test functionality
-    print 'Enter test arguments: ',
-    line = sys.stdin.readline()[:-1].split(' ')
-    dictarg(adict, line)
-    print adict