def run(name, *args, **kwargs):
    """
    DEPRECATION WARNING: This function is deprecated as of Cement 2.7.x and
    will be removed in future versions of Cement.
    Use ``CementApp.hook.run()`` instead.

    ---

    Run all defined hooks in the namespace.  Yields the result of each hook
    function run.

    :param name: The name of the hook function.
    :param args: Additional arguments to be passed to the hook functions.
    :param kwargs: Additional keyword arguments to be passed to the hook
        functions.
    :raises: FrameworkError

    Usage:

    .. code-block:: python

        from cement.core import hook

        for result in hook.run('hook_name'):
            # do something with result from each hook function
            ...
    """
    # only log debug for now as this won't be removed until Cement 3.x and
    # we don't have access to CementApp.Meta.ignore_deprecation_warnings here
    LOG.debug(
        'Cement Deprecation Warning: `hook.run()` has been deprecated, '
        'and will be removed in future versions of Cement.  You should now '
        'use `CementApp.hook.run()` instead.'
    )
    if name not in backend.__hooks__:
        raise exc.FrameworkError("Hook name '%s' is not defined!" % name)

    # Will order based on weight (the first item in the tuple)
    backend.__hooks__[name].sort(key=operator.itemgetter(0))
    for hook in backend.__hooks__[name]:
        LOG.debug("running hook '%s' (%s) from %s" %
                  (name, hook[2], hook[2].__module__))
        res = hook[2](*args, **kwargs)

        # Check if result is a nested generator - needed to support e.g.
        # asyncio
        if isinstance(res, types.GeneratorType):
            for _res in res:
                yield _res
        else:
            yield res
dataset/ETHPy150Open datafolklabs/cement/cement/core/hook.py/run/original