Source code for

# Copyright(C) 2010-2011 Romain Bignon
# This file is part of woob.
# woob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# woob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with woob. If not, see <>.

[docs]class ConfigError(Exception): pass
[docs]class IConfig: """ Interface for config storage. Config stores keys and values. Each key is a path of components, allowing to group multiple options. """
[docs] def load(self, default={}): """ Load config. :param default: default values for the config :type default: dict[:class:`str`] """ raise NotImplementedError()
[docs] def save(self): """Save config.""" raise NotImplementedError()
[docs] def set(self, *args): """ Set a config value. :param args: all args except the last arg are the path of the option key. :type args: str or object """ raise NotImplementedError()
[docs] def delete(self, *args): """ Delete an option from config. :param args: path to the option key. :type args: str """ raise NotImplementedError()
[docs] def get(self, *args, **kwargs): """ Get the value of an option. :param args: path of the option key. :param default: if specified, default value when path is not found """ raise NotImplementedError()
def __enter__(self): self.load() def __exit__(self, t, v, tb):