Mercurial > hg > configuration
changeset 84:34c13cde0255
move towards dict or items system
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 Apr 2012 13:39:13 -0700 |
parents | 19834bc83d13 |
children | a2d8e7bbb95f |
files | configuration/configuration.py |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/configuration/configuration.py Tue Apr 17 12:50:29 2012 -0700 +++ b/configuration/configuration.py Fri Apr 27 13:39:13 2012 -0700 @@ -231,6 +231,15 @@ def __init__(self, configuration_providers=configuration_providers, types=types, load=None, dump='--dump', **parser_args): + # sanity check + if isinstance(self.options, dict): + self.option_dict = self.options + elif isinstance(self.options, list): + # XXX could also be tuple, etc + self.option_dict = dict(self.options) + else: + raise NotImplementedError + # setup configuration self.config = {} self.configuration_providers = configuration_providers @@ -270,7 +279,9 @@ def items(self): # TODO: allow options to be a list of 2-tuples - return self.options.items() + if isinstance(self.options, dict): + return self.options.items() + return self.options ### methods for validating configuration