This file is indexed.

/usr/lib/python3/dist-packages/nibabel/deprecated.py is in python3-nibabel 2.2.1-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
""" Module to help with deprecating objects and classes
"""

import warnings

from .deprecator import Deprecator
from .info import cmp_pkg_version


class ModuleProxy(object):
    """ Proxy for module that may not yet have been imported

    Parameters
    ----------
    module_name : str
        Full module name e.g. ``nibabel.minc``

    Examples
    --------

    ::
        arr = np.arange(24).reshape((2, 3, 4))
        minc = ModuleProxy('nibabel.minc')
        minc_image = minc.Minc1Image(arr, np.eye(4))

    So, the ``minc`` object is a proxy that will import the required module
    when you do attribute access and return the attributes of the imported
    module.
    """

    def __init__(self, module_name):
        self._module_name = module_name

    def __hasattr__(self, key):
        mod = __import__(self._module_name, fromlist=[''])
        return hasattr(mod, key)

    def __getattr__(self, key):
        mod = __import__(self._module_name, fromlist=[''])
        return getattr(mod, key)

    def __repr__(self):
        return "<module proxy for {0}>".format(self._module_name)


class FutureWarningMixin(object):
    """ Insert FutureWarning for object creation

    Examples
    --------
    >>> class C(object): pass
    >>> class D(FutureWarningMixin, C):
    ...     warn_message = "Please, don't use this class"

    Record the warning

    >>> with warnings.catch_warnings(record=True) as warns:
    ...     d = D()
    ...     warns[0].message
    FutureWarning("Please, don't use this class",)
    """
    warn_message = 'This class will be removed in future versions'

    def __init__(self, *args, **kwargs):
        warnings.warn(self.warn_message,
                      FutureWarning,
                      stacklevel=2)
        super(FutureWarningMixin, self).__init__(*args, **kwargs)


class VisibleDeprecationWarning(UserWarning):
    """ Deprecation warning that will be shown by default

    Python >= 2.7 does not show standard DeprecationWarnings by default:

    http://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x

    Use this class for cases where we do want to show deprecations by default.
    """
    pass


deprecate_with_version = Deprecator(cmp_pkg_version)