Mercurial > hg > configuration
changeset 29:fadcc6ab51d4
more (de/)serialization stubbing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 26 Mar 2012 17:00:12 -0700 |
parents | c516ab813079 |
children | b27a7cb2dd5b |
files | configuration/config.py |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/configuration/config.py Mon Mar 26 16:54:37 2012 -0700 +++ b/configuration/config.py Mon Mar 26 17:00:12 2012 -0700 @@ -145,13 +145,18 @@ __all__ += [i.__name__ for i in types.values()] class Configuration(object): - options = {} + """declarative configuration object""" + + options = {} # configuration basis def __init__(self, configuration_providers=configuration_providers, types=types): self.config = {} self.configuration_providers = configuration_providers self.types = types + ### methods for iteration + ### TODO: make this a real iterator + def items(self): # TODO: allow options to be a list of 2-tuples return self.options.items() @@ -262,10 +267,12 @@ def serialize(self, filename, format=None): """serialize configuration to a file""" + # TODO: allow file object vs file name def deserialize(self, filename, format=None): """load configuration from a file""" + # TODO: allow file object vs file name - extension = os.path.splitext(filename)[-1] - if not extension: - return None + if not format: + extension = os.path.splitext(filename)[-1] +