Commits

Tim Tomes committed d9d35dc

updated the framework to accept case insensitive options.

Comments (0)

Files changed (2)

core/framework.py

     def register_option(self, name, value, reqd, desc, options=None):
         # can't use not because empty dictonary would eval as true
         if options == None: options = self.options
-        options[name] = {'value':value, 'reqd':reqd, 'desc':desc}
+        options[name.lower()] = {'value':value, 'reqd':reqd, 'desc':desc}
 
     def validate_options(self):
         for option in self.options:
                 value = self.options[key]['value'] if self.options[key]['value'] else ''
                 reqd = self.options[key]['reqd']
                 desc = self.options[key]['desc']
-                print pattern % (key.ljust(key_len), str(value).ljust(val_len), reqd.ljust(3), desc)
+                print pattern % (key.upper().ljust(key_len), str(value).ljust(val_len), reqd.ljust(3), desc)
             print ''
         else:
             if params != 'info': print ''
         options = params.split()
         if len(options) < 2: self.help_set()
         else:
-            name = options[0]
+            name = options[0].lower()
             if name in self.options:
                 value = ' '.join(options[1:])
-                print '%s => %s' % (name, value)
+                print '%s => %s' % (name.upper(), value)
                 self.options[name]['value'] = self.autoconvert(value)
             else: self.error('Invalid option.')
 
         options = params.split()
         if len(options) < 2: self.help_set()
         else:
-            name = options[0]
+            name = options[0].lower()
             if name in self.options:
                 value = ' '.join(options[1:])
                 # make sure database file is valid
                         self.error('Invalid path or name for \'%s\'.' % (name))
                         return
                     self.init_db()
-                print '%s => %s' % (name, value)
+                print '%s => %s' % (name.upper(), value)
                 self.options[name]['value'] = self.autoconvert(value)
             else: self.error('Invalid option.')