This file is indexed.

/usr/lib/python2.7/dist-packages/testfixtures/utils.py is in python-testfixtures 4.14.3-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
# Copyright (c) 2008-2011 Simplistix Ltd
# See license.txt for license details.
from textwrap import dedent

from functools import wraps
from inspect import getargspec


def generator(*args):
    """
    A utility function for creating a generator that will yield the
    supplied arguments.
    """
    for i in args:
        yield i


class Wrappings:
    def __init__(self):
        self.before = []
        self.after = []


def wrap(before, after=None):
    """
    A decorator that causes the supplied callables to be called before
    or after the wrapped callable, as appropriate.
    """
    def wrapper(wrapped):
        if getattr(wrapped, '_wrappings', None) is None:
            w = Wrappings()

            @wraps(wrapped)
            def wrapping(*args, **kw):
                args = list(args)
                to_add = len(getargspec(wrapped)[0][len(args):])
                added = 0
                for c in w.before:
                    r = c()
                    if added < to_add:
                        args.append(r)
                        added += 1
                try:
                    return wrapped(*args, **kw)
                finally:
                    for c in w.after:
                        c()
            f = wrapping
            f._wrappings = w
        else:
            f = wrapped
        w = f._wrappings
        w.before.append(before)
        if after is not None:
            w.after.insert(0, after)
        return f
    return wrapper


def extend_docstring(docstring, objs):
    for obj in objs:
        try:
            obj.__doc__ = dedent(obj.__doc__) + docstring
        except (AttributeError, TypeError):  # python 2 or pypy 4.0.1 :-(
            pass