def get_plugin(plugin_id_or_class, env=None):
    """Looks up the plugin instance by id or class."""
    if env is None:
        ctx = get_ctx()
        if ctx is None:
            raise RuntimeError('Context is unavailable and no enviroment '
                               'was passed to the function.')
        env = ctx.env
    plugin_id = env.plugin_ids_by_class.get(plugin_id_or_class,
                                            plugin_id_or_class)
    try:
        return env.plugins[plugin_id]
    except KeyError:
        raise LookupError('Plugin %r not found' % plugin_id)
dataset/ETHPy150Open lektor/lektor-archive/lektor/pluginsystem.py/get_plugin/original