This file is indexed.

/usr/lib/python3/dist-packages/python_utils/import_.py is in python3-python-utils 2.2.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
class DummyException(Exception):
    pass


def import_global(
        name, modules=None, exceptions=DummyException, locals_=None,
        globals_=None, level=-1):
    '''Import the requested items into the global scope

    WARNING! this method _will_ overwrite your global scope
    If you have a variable named "path" and you call import_global('sys')
    it will be overwritten with sys.path

    Args:
        name (str): the name of the module to import, e.g. sys
        modules (str): the modules to import, use None for everything
        exception (Exception): the exception to catch, e.g. ImportError
        `locals_`: the `locals()` method (in case you need a different scope)
        `globals_`: the `globals()` method (in case you need a different scope)
        level (int): the level to import from, this can be used for
        relative imports
    '''
    frame = None
    try:
        # If locals_ or globals_ are not given, autodetect them by inspecting
        # the current stack
        if locals_ is None or globals_ is None:
            import inspect
            frame = inspect.stack()[1][0]

            if locals_ is None:
                locals_ = frame.f_locals

            if globals_ is None:
                globals_ = frame.f_globals

        try:
            name = name.split('.')

            # Relative imports are supported (from .spam import eggs)
            if not name[0]:
                name = name[1:]
                level = 1

            # raise IOError((name, level))
            module = __import__(
                name=name[0] or '.',
                globals=globals_,
                locals=locals_,
                fromlist=name[1:],
                level=max(level, 0),
            )

            # Make sure we get the right part of a dotted import (i.e.
            # spam.eggs should return eggs, not spam)
            try:
                for attr in name[1:]:
                    module = getattr(module, attr)
            except AttributeError:
                raise ImportError('No module named ' + '.'.join(name))

            # If no list of modules is given, autodetect from either __all__
            # or a dir() of the module
            if not modules:
                modules = getattr(module, '__all__', dir(module))
            else:
                modules = set(modules).intersection(dir(module))

            # Add all items in modules to the global scope
            for k in set(dir(module)).intersection(modules):
                if k and k[0] != '_':
                    globals_[k] = getattr(module, k)
        except exceptions as e:
            return e
    finally:
        # Clean up, just to be sure
        del name, modules, exceptions, locals_, globals_, frame