# HG changeset patch # User Jeff Hammel # Date 1335809237 25200 # Node ID 91e213025769f23e8bc5dc7386b4e2276a846de7 # Parent 0c47bcb63048021f609e1539ca199e3790a16dce handle None type (though its probably a bogus case) and note on future failure upon coercion diff -r 0c47bcb63048 -r 91e213025769 configuration/configuration.py --- a/configuration/configuration.py Sun Apr 29 19:18:11 2012 -0700 +++ b/configuration/configuration.py Mon Apr 30 11:07:17 2012 -0700 @@ -361,16 +361,28 @@ return getattr(handler, 'take_action', lambda x: 1) def option_type(self, name): + """get the type of an option named `name`""" + value = self.option_dict[name] if 'type' in value: return value['type'] if 'default' in value: + default = value['default'] + if default is None: + return None return type(value['default']) def optparse_options(self, parser): """add optparse options to a OptionParser instance""" for key, value in self.items(): - handler = self.types[self.option_type(key)] + try: + handler = self.types[self.option_type(key)] + except: + # XXX print this for now + # ultimately, if an option can't be coerced to a type + # we should just not add a CLI handler for it + print key, value + raise args, kw = handler(key, value) if not args: # No CLI interface