This file is indexed.

/usr/lib/python3/dist-packages/pyvisa/ctwrapper/cthelper.py is in python3-pyvisa 1.8-2.

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
# -*- coding: utf-8 -*-
"""
    pyvisa.ctwrapper._ct
    ~~~~~~~~~~~~~~~~~~~~

    Cross platform helper of ctypes.

    This file is part of PyVISA.

    :copyright: 2014 by PyVISA Authors, see AUTHORS for more details.
    :license: MIT, see LICENSE for more details.
"""

from __future__ import division, unicode_literals, print_function, absolute_import

# ctypes and os shouldn't be re-exported.
import os as _os
import sys as _sys

import ctypes as _ctypes

PYTHON3 = _sys.version_info >= (3, 0)

if _os.name == 'nt':
    FUNCTYPE, Library = _ctypes.WINFUNCTYPE, _ctypes.WinDLL
else:
    FUNCTYPE, Library = _ctypes.CFUNCTYPE, _ctypes.CDLL

# On Linux, find Library returns the name not the path.
# This excerpt provides a modified find_library.
# noinspection PyUnresolvedReferences
if _os.name == "posix" and _sys.platform.startswith('linux'):

    # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
    def define_find_libary():
        import re
        import tempfile
        import errno

        def _findlib_gcc(name):
            expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
            fdout, ccout = tempfile.mkstemp()
            _os.close(fdout)
            cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; else CC=cc; fi;' \
                  '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
            trace = ''
            try:
                f = _os.popen(cmd)
                trace = f.read()
                f.close()
            finally:
                try:
                    _os.unlink(ccout)
                except OSError as e:
                    if e.errno != errno.ENOENT:
                        raise
            res = re.search(expr, trace)
            if not res:
                return None
            return res.group(0)

        def _findlib_ldconfig(name):
            # XXX assuming GLIBC's ldconfig (with option -p)
            expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
            res = re.search(expr,
                            _os.popen('/sbin/ldconfig -p 2>/dev/null').read())
            if not res:
                # Hm, this works only for libs needed by the python executable.
                cmd = 'ldd %s 2>/dev/null' % _sys.executable
                res = re.search(expr, _os.popen(cmd).read())
                if not res:
                    return None
            return res.group(0)

        def _find_library(name):
            path = _findlib_ldconfig(name) or _findlib_gcc(name)
            if path:
                return _os.path.realpath(path)
            return path

        return _find_library

    find_library = define_find_libary()
else:
    from ctypes.util import find_library