Verify that some dependent configuration is present and correct.

    This will generally be called from a
    :meth:`~yakonfig.Configurable.check_config` implementation.
    `what` is a :class:`~yakonfig.Configurable`-like object.  If the
    corresponding configuration isn't present in the global
    configuration, raise a :exc:`yakonfig.ConfigurationError`
    explaining that `who` required it.  Otherwise call that module's
    :meth:`~yakonfig.Configurable.check_config` (if any).

    :param yakonfig.Configurable what: top-level module to require
    :param str who: name of the requiring module
    :raise yakonfig.ConfigurationError: if configuration for
      `what` is missing or incorrect

def check_toplevel_config(what, who):
    """Verify that some dependent configuration is present and correct.

    This will generally be called from a
    :meth:`~yakonfig.Configurable.check_config` implementation.
    `what` is a :class:`~yakonfig.Configurable`-like object.  If the
    corresponding configuration isn't present in the global
    configuration, raise a :exc:`yakonfig.ConfigurationError`
    explaining that `who` required it.  Otherwise call that module's
    :meth:`~yakonfig.Configurable.check_config` (if any).

    :param yakonfig.Configurable what: top-level module to require
    :param str who: name of the requiring module
    :raise yakonfig.ConfigurationError: if configuration for
      `what` is missing or incorrect

    """
    config_name = what.config_name
    config = get_global_config()
    if config_name not in config:
        raise ConfigurationError(
            '{0} requires top-level configuration for {1}'
            .format(who, config_name))
    checker = getattr(what, 'check_config', None)
    if checker:
        checker(config[config_name], config_name)