def run(self, name, *args, **kwargs):
        """
        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.foundation import CementApp

            def my_hook_func(app):
                # do something with app?
                return True

            with CementApp('myapp') as app:
                app.hook.define('my_hook_name')
                app.hook.register('my_hook_name', my_hook_func)
                for res in app.hook.run('my_hook_name', self):
                    # do something with the result?
                    pass

        """
        if name not in self.__hooks__:
            raise exc.FrameworkError("Hook name '%s' is not defined!" % name)

        # Will order based on weight (the first item in the tuple)
        self.__hooks__[name].sort(key=operator.itemgetter(0))
        for hook in self.__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


# the following is only used for backward compat with < 2.7.x!
dataset/ETHPy150Open datafolklabs/cement/cement/core/hook.py/HookManager.run/original