This file is indexed.

/usr/lib/python2.7/dist-packages/instant/config.py is in python-instant 1.3.0-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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"""This module contains helper functions for configuration using pkg-config."""

import os
from .output import get_status_output
import re

# Global cache variables
_swig_binary_cache = None
_swig_version_cache = None
_pkg_config_installed = None
_header_and_library_cache = {}

def check_and_set_swig_binary(binary="swig", path=""):
    """ Check if a particular swig binary is available"""
    global _swig_binary_cache
    if not isinstance(binary, str):
        raise TypeError("expected a 'str' as first argument")
    if not isinstance(path, str):
        raise TypeError("expected a 'str' as second argument")
    swig_binary = os.path.join(path, binary)
    if swig_binary == _swig_binary_cache:
        return True
    
    result, output = get_status_output("%s -version"%swig_binary)
    if result != 0: 
        return False
    
    # Set binary cache
    _swig_binary_cache = swig_binary

    # Reset SWIG version cache
    pattern = "SWIG Version (.*)"
    r = re.search(pattern, output)
    _swig_version_cache = r.groups(0)[0]
    
    return True

def get_swig_binary():
    "Return any cached swig binary"
    return _swig_binary_cache if _swig_binary_cache else "swig"

def get_swig_version():
    """ Return the current swig version in a 'str'"""
    global _swig_version_cache
    if _swig_version_cache is None:
        # Check for swig installation
        result, output = get_status_output("%s -version"%get_swig_binary())
        if result != 0: 
            raise OSError("SWIG is not installed on the system.")
        pattern = "SWIG Version (.*)"
        r = re.search(pattern, output)
        _swig_version_cache = r.groups(0)[0]
    return _swig_version_cache

def check_swig_version(version, same=False):
    """ Check the swig version

    Returns True if the version of the installed swig is equal or greater than the
    version passed to the function.

    If same is True, the function returns True if and only if the two versions
    are the same.
    
    Usage:
    if instant.check_swig_version('1.3.36'):
        print "Swig version is greater than or equal to 1.3.36"
    else:
        print "Swig version is lower than 1.3.36"
    """
    assert isinstance(version,str), "Provide the first version number as a 'str'"
    assert len(version.split("."))==3, "Provide the version number as three numbers seperated by '.'"

    installed_version = list(map(int, get_swig_version().split('.')))
    handed_version    = list(map(int, version.split('.')))
    
    # If same is True then just check that all numbers are equal
    if same:
        return all(i == h for i, h in zip(installed_version,handed_version))
    
    swig_enough = True
    for i, v in enumerate([v for v in installed_version]):
        if handed_version[i] < v:
            break
        elif handed_version[i] == v:
            continue
        else:
            swig_enough = False
        break
    
    return swig_enough

def header_and_libs_from_pkgconfig(*packages, **kwargs):
    """This function returns list of include files, flags,
    libraries and library directories obtain from a pkgconfig file.
    
    The usage is: 
      (includes, flags, libraries, libdirs) = \
             header_and_libs_from_pkgconfig(*list_of_packages)
    or:
        (includes, flags, libraries, libdirs, linkflags) = \
             header_and_libs_from_pkgconfig(*list_of_packages, \
             returnLinkFlags=True)
    """
    global _pkg_config_installed, _header_and_library_cache
    returnLinkFlags = kwargs.get("returnLinkFlags", False)
    if _pkg_config_installed is None:
        result, output = get_status_output("pkg-config --version ")
        _pkg_config_installed = (result == 0)
    if not _pkg_config_installed:
        raise OSError("The pkg-config package is not installed on the system.")

    env = os.environ.copy()
    try:
        assert env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] == "0"
    except:
        env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "1"

    includes = []
    flags = []
    libs = []
    libdirs = []
    linkflags = []
    for pack in packages:
        if not pack in _header_and_library_cache:
            result, output = get_status_output(\
                "pkg-config --exists %s " % pack, env=env)
            if result == 0: 
                tmp = get_status_output(\
                    "pkg-config --cflags-only-I %s " % pack, env=env)[1].split()
                _includes = [i[2:] for i in tmp]

                _flags = get_status_output(\
                    "pkg-config --cflags-only-other %s " % pack, env=env)[1].split()

                tmp = get_status_output(\
                    "pkg-config --libs-only-l  %s " % pack, env=env)[1].split()
                _libs = [i[2:] for i in tmp]

                tmp = get_status_output(\
                    "pkg-config --libs-only-L  %s " % pack, env=env)[1].split()
                _libdirs = [i[2:] for i in tmp]

                _linkflags = get_status_output(\
                    "pkg-config --libs-only-other  %s " % pack, env=env)[1].split()

                _header_and_library_cache[pack] = (_includes, _flags, _libs, \
                                                   _libdirs, _linkflags)
            else:
                _header_and_library_cache[pack] = None

        result = _header_and_library_cache[pack]
        if not result:
            raise OSError("The pkg-config file %s does not exist" % pack)

        _includes, _flags, _libs, _libdirs, _linkflags = result
        includes.extend(_includes)
        flags.extend(_flags)
        libs.extend(_libs)
        libdirs.extend(_libdirs)
        linkflags.extend(_linkflags)

    if returnLinkFlags:
        return (includes, flags, libs, libdirs, linkflags)
    return (includes, flags, libs, libdirs)