This file is indexed.

/usr/lib/python3/dist-packages/provisioningserver/utils/events.py is in python3-maas-provisioningserver 2.4.0~beta2-6865-gec43e47e6-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2015-2016 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Event-related utilities."""

__all__ = [
    "Event",
    "EventGroup",
    ]


class Event:
    """Simple event that when fired calls all of the registered handlers on
    this event."""

    def __init__(self):
        self.handlers = set()

    def registerHandler(self, handler):
        """Register handler to event."""
        self.handlers.add(handler)

    def unregisterHandler(self, handler):
        """Unregister handler from event."""
        self.handlers.discard(handler)

    def fire(self, *args, **kwargs):
        """Fire the event."""
        # Shallow-copy the set to avoid "size changed during iteration"
        # errors. This is a fast operation: faster than switching to an
        # immutable set or using thread-safe locks (and won't deadlock).
        for handler in self.handlers.copy():
            handler(*args, **kwargs)


class EventGroup:
    """Group of events.

    Provides a quick way of creating a group of events for an object. Access
    the events as properties on this object.

    Example:
        events = EventGroup("connected", "disconnected")
        events.connected.fire()
        events.disconnected.fire()
    """

    def __init__(self, *events):
        for event in events:
            setattr(self, event, Event())