This file is indexed.

/usr/lib/python2.7/dist-packages/circuits/core/loader.py is in python-circuits 3.1.0+ds1-1.

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
51
52
53
54
55
56
57
58
59
60
61
62
63
# Package:  loader
# Date:     16th March 2011
# Author:   James Mills, jamesmills at comops dot com dot au

"""
This module implements a generic Loader suitable for dynamically loading
components from other modules. This supports loading from local paths,
eggs and zip archives. Both setuptools and distribute are fully supported.
"""

import sys
from inspect import getmembers, getmodule, isclass

from .handlers import handler
from .utils import safeimport
from .components import BaseComponent


class Loader(BaseComponent):
    """Create a new Loader Component

    Creates a new Loader Component that enables dynamic loading of
    components from modules either in local paths, eggs or zip archives.
    """

    channel = "loader"

    def __init__(self, auto_register=True, init_args=None,
                 init_kwargs=None, paths=None, channel=channel):
        "initializes x; see x.__class__.__doc__ for signature"

        super(Loader, self).__init__(channel=channel)

        self._auto_register = auto_register
        self._init_args = init_args or tuple()
        self._init_kwargs = init_kwargs or dict()

        if paths:
            for path in paths:
                sys.path.insert(0, path)

    @handler("load")
    def load(self, name):
        module = safeimport(name)
        if module is not None:

            test = lambda x: isclass(x) \
                and issubclass(x, BaseComponent) \
                and getmodule(x) is module
            components = [x[1] for x in getmembers(module, test)]

            if components:
                TheComponent = components[0]

                component = TheComponent(
                    *self._init_args,
                    **self._init_kwargs
                )

                if self._auto_register:
                    component.register(self)

                return component