INNER CODE UNIT · Python

__new__

opsdroid/opsdroid · opsdroid/connector/__init__.py:47

    def __new__(cls, *args, **kwargs):
        """Create the class object.

        Before constructing the class parse all the methods that have been
        decorated with ``register_event``.
        """
        # Get all 'function' members as the wrapped methods are functions
        # This returns a tuple of (name, function) for each method.
        functions = inspect.getmembers(cls, predicate=inspect.isfunction)

        # Filter out anything that's not got the attribute __opsdroid_event__
        event_methods = filter(
            lambda f: hasattr(f, "__opsdroid_events__"),
            # Just extract the function objects
            map(lambda t: t[1], functions),
        )

        # If we don't have the event call the unknown event coroutine

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…