@contextlib.contextmanager<EOL>def defaulted_config(modules, params=None, yaml=None, filename=None,<EOL>config=None, validate=True):
with _temporary_config():<EOL><INDENT>set_default_config(modules, params=params, yaml=yaml,<EOL>filename=filename, config=config, validate=validate)<EOL>yield get_global_config()<EOL><DEDENT>
Context manager version of :func:`set_default_config()`.

    Use this with a Python 'with' statement, like

    >>> config_yaml = '''
    ... toplevel:
    ...   param: value
    ... '''
    >>> with yakonfig.defaulted_config([toplevel], yaml=config_yaml) as config:
    ...    assert 'param' in config['toplevel']
    ...    assert yakonfig.get_global_config('toplevel', 'param') == 'value'

    On exit the global configuration is restored to its previous state
    (if any).

    :param modules: modules or Configurable instances to use
    :type modules: iterable of :class:`~yakonfig.Configurable`
    :param dict params: dictionary of command-line argument key to values
    :param str yaml: global configuration file
    :param str filename: location of global configuration file
    :param dict config: global configuration object
    :param bool validate: check configuration after creating
    :return: the new global configuration