This file is indexed.

/usr/lib/python3/dist-packages/pyutilib/component/loader/plugin_eggLoader.py is in python3-pyutilib 5.3.5-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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#  _________________________________________________________________________
#
#  PyUtilib: A Python utility library.
#  Copyright (c) 2008 Sandia Corporation.
#  This software is distributed under the BSD License.
#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
#  the U.S. Government retains certain rights in this software.
#  _________________________________________________________________________

# This software is adapted from the Trac software (specifically, the trac.core
# module.  The Trac copyright statement is included below.

__all__ = ['EggLoader']

import os
import sys
import logging
from pyutilib.component.core import *
from pyutilib.component.config import *

try:
    if not 'pkg_resources' in sys.modules:
        #
        # Avoid a re-import, which causes setup.py warnings...
        #
        import pkg_resources
    from pkg_resources import working_set, DistributionNotFound, VersionConflict, UnknownExtra, Environment
    pkg_resources_avail=True
    def pkg_environment(path):
        return Environment(path)
except ImportError:
    def pkg_environment(path):
        return None
    pkg_resources_avail=False

logger = logging.getLogger('pyutilib.component.core.pca')


class EggLoader(ManagedPlugin):
    """
    Loader that looks for Python egg files in the plugins directories.
    These files get exampled with the pkg_resources package, and
    Plugin classes are loaded.

    Note: this plugin should not be directly constructed.  Instead,
    the user should employ the PluginFactory_EggLoader function.
    """

    implements(IPluginLoader, service=True)

    def __init__(self, **kwds):
        """EggLoader constructor.  The 'namespace' keyword option is
        required."""
        if 'name' not in kwds:
            kwds['name'] = "EggLoader."+kwds['namespace']
        super(EggLoader,self).__init__(**kwds)
        self.entry_point_name = kwds['namespace']+".plugins"
        if not pkg_resources_avail:
            logger.warning('A dummy EggLoader service is being constructed, because the pkg_resources package is not available on this machine.')

    def load(self, env, search_path, disable_re, name_re):
        generate_debug_messages = __debug__ and env.log.isEnabledFor(logging.DEBUG)
        if not pkg_resources_avail:
            if generate_debug_messages:
                env.log.debug('The EggLoader service is terminating early because the pkg_resources package is not available on this machine.')
            return

        env.log.info('BEGIN -  Loading plugins with an EggLoader service')
        distributions, errors = working_set.find_plugins(
            pkg_environment(search_path)
        )
        for dist in distributions:
            if name_re.match(str(dist)):
                if generate_debug_messages:
                    env.log.debug('Adding plugin %r from %r', dist, dist.location)
                working_set.add(dist)
            else:
                if generate_debug_messages:
                    env.log.debug('Ignoring plugin %r from %r', dist, dist.location)

        def _log_error(item, e):
            gen_debug = __debug__ and env.log.isEnabledFor(logging.DEBUG)
            if isinstance(e, DistributionNotFound):
                if gen_debug:
                    env.log.debug('Skipping "%s": ("%s" not found)', item, e)
            elif isinstance(e, VersionConflict):
                if gen_debug:
                    env.log.debug('Skipping "%s": (version conflict "%s")',
                                  item, e)
            elif isinstance(e, UnknownExtra):
                env.log.error('Skipping "%s": (unknown extra "%s")', item, e)
            elif isinstance(e, ImportError):
                env.log.error('Skipping "%s": (can\'t import "%s")', item, e)
            else:
                env.log.error('Skipping "%s": (error "%s")', item, e)

        for dist, e in errors.items():
            _log_error(dist, e)

        for entry in working_set.iter_entry_points(self.entry_point_name):
            if generate_debug_messages:
                env.log.debug('Loading %r from %r', entry.name,
                          entry.dist.location)
            try:
                entry.load(require=True)
            except (ImportError, DistributionNotFound, VersionConflict,
                    UnknownExtra):
                e = sys.exc_info()[1]
                _log_error(entry, e)
            else:
                if not disable_re.match(os.path.dirname(entry.module_name)) is None:
                    #_enable_plugin(env, entry.module_name)
                    pass

        env.log.info('END -    Loading plugins with an EggLoader service')


# Copyright (C) 2005-2008 Edgewall Software
# Copyright (C) 2005-2006 Christopher Lenz <cmlenz@gmx.de>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
#
# Author: Christopher Lenz <cmlenz@gmx.de>