This file is indexed.

/usr/lib/python3/dist-packages/pyutilib/component/config/env_config.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
#  _________________________________________________________________________
#
#  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.
#  _________________________________________________________________________

"""A plugin that supports configuration of environment options."""

import os.path
import os
import re
import logging

from pyutilib.component.config.options import *

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


class IEnvironmentConfig(Interface):
    """Interface for environment configuration."""

    def get_option(self, option):
        """Return the value of the specified option."""

    def matches(self, namespace):
        """
        Returns a tuple (flag,count).  The flag is true if this
        environment is a parent of the specified namespace.  If the flag is
        true, then the count is the number of levels in the namespace.
        """


class EnvironmentConfig(Plugin):
    """A plugin that supports configuration of environment options."""

    implements(IEnvironmentConfig)
    implements(IPluginLoadPath)

    def __init__(self, namespace):
        self.namespace = namespace
        self.p = re.compile(namespace)
        declare_option("options", cls=DictOption, section=namespace)

    def get_option(self, option):
        try:
            return getattr(self.options, option)
        except AttributeError:
            return None

    def matches(self, namespace):
        if self.p.match(namespace) is None:
            return (False,0)
        return (True, namespace.count('.')+1)

    def get_load_path(self):
        ans = []
        #
        # Look for load_path in the environment
        #
        try:
            ans.append( os.path.normcase(os.path.realpath(self.options.load_path )) )
        except OptionError:
            pass
        except AttributeError:
            pass
        #
        # Look for the $HOME/.$name/plugin directory
        #
        if "HOME" in os.environ:
            dir =  os.path.normcase(os.path.realpath(os.path.join(os.environ["HOME"], "."+self.namespace, "plugins")))
            if os.path.exists(dir):
                ans.append(dir)
        #
        # Look for the $PLUGINPATH environment
        #
        if "PLUGINPATH" in os.environ:
            tmp = os.environ["PLUGINPATH"]
            if ';' in tmp:
                ans += tmp.split(';')
            elif ':' in tmp:
                ans += tmp.split(':')
            else:
                ans += re.split('[ \t]+',tmp)
        if __debug__ and logger.isEnabledFor(logging.DEBUG):
            logger.debug("Created load path: %s" % ans)
        return ans