Load and initialize plugins

def _load_plugins(config, cfgparser):
    """Load and initialize plugins
    """
    # set umask before any plugin gets a chance to create a file
    os.umask(config['umask'])

    for s in cfgparser.sections():
        if s in {'ENV', 'global'}:
            # ENV section is only used for interpolation
            continue

        if s.startswith('/'):
            menu = 'consumers'
            path_chain = s.split('/')
            if path_chain[-1] == '':
                path_chain = path_chain[:-1]
            name = tuple(path_chain)
        else:
            if s.startswith('auth:'):
                menu = 'authenticators'
                name = s[5:]
            elif s.startswith('authz:'):
                menu = 'authorizers'
                name = s[6:]
            elif s.startswith('store:'):
                menu = 'stores'
                name = s[6:]
            else:
                raise ValueError('Invalid section name [%s].\n' % s)

        try:
            config[menu][name] = _create_plugin(cfgparser, s, menu)
        except Exception as e:
            logger.debug("Plugin '%s' failed to load.", name, exc_info=True)
            raise RuntimeError(menu, name, e)

    # 2nd initialization stage
    for menu in ['authenticators', 'authorizers', 'consumers', 'stores']:
        plugins = config[menu]
        for name in sorted(plugins):
            plugin = plugins[name]
            plugin.finalize_init(config, cfgparser, context=None)