Mercurial > hg > configuration
changeset 86:6067ae61cd17
use self.option_dict
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 Apr 2012 13:57:21 -0700 |
parents | a2d8e7bbb95f |
children | 928654373755 |
files | configuration/configuration.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/configuration/configuration.py Fri Apr 27 13:44:12 2012 -0700 +++ b/configuration/configuration.py Fri Apr 27 13:57:21 2012 -0700 @@ -291,15 +291,15 @@ """ # ensure options in configuration are in self.options - unknown_options = [i for i in config if i not in self.options] + unknown_options = [i for i in config if i not in self.option_dict] if unknown_options: raise UnknownOptionException("Unknown options: %s" % ', '.join(unknown_options)) # ensure options are of the right type (if specified) for key, value in config.items(): - _type = self.options[key].get('type') - if _type is None and 'default' in self.options[key]: - _type = type(self.options[key]['default']) + _type = self.option_dict[key].get('type') + if _type is None and 'default' in self.option_dict[key]: + _type = type(self.option_dict[key]['default']) if _type is not None and not isinstance(value, _type): try: config[key] = _type(value) @@ -352,7 +352,7 @@ ### XXX could go in a subclass def cli_formatter(self, option): - handler = self.types[self.options[option].get('type')] + handler = self.types[self.option_dict[option].get('type')] return getattr(handler, 'take_action', lambda x: 1) def optparse_options(self, parser): @@ -372,7 +372,7 @@ # get CLI configuration options cli_config = dict([(key, value) for key, value in options.__dict__.items() - if key in self.options and key in self.parsed]) + if key in self.option_dict and key in self.parsed]) # deserialize configuration configuration_files = getattr(options, 'load', args)