This file is indexed.

/usr/lib/python2.7/dist-packages/pyqtgraph/util/cprint.py is in python-pyqtgraph 0.9.10-5.

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
"""
Cross-platform color text printing

Based on colorama (see pyqtgraph/util/colorama/README.txt)
"""
import sys, re

from .colorama.winterm import WinTerm, WinColor, WinStyle
from .colorama.win32 import windll

_WIN = sys.platform.startswith('win')
if windll is not None:
    winterm = WinTerm()
else:
    _WIN = False

def winset(reset=False, fore=None, back=None, style=None, stderr=False):
    if reset:
        winterm.reset_all()
    if fore is not None:
        winterm.fore(fore, stderr)
    if back is not None:
        winterm.back(back, stderr)
    if style is not None:
        winterm.style(style, stderr)

ANSI = {}
WIN = {}
for i,color in enumerate(['BLACK', 'RED', 'GREEN', 'YELLOW', 'BLUE', 'MAGENTA', 'CYAN', 'WHITE']):
    globals()[color] = i
    globals()['BR_' + color] = i + 8
    globals()['BACK_' + color] = i + 40
    ANSI[i] = "\033[%dm" % (30+i)
    ANSI[i+8] = "\033[2;%dm" % (30+i)
    ANSI[i+40] = "\033[%dm" % (40+i)
    color = 'GREY' if color == 'WHITE' else color
    WIN[i] = {'fore': getattr(WinColor, color), 'style': WinStyle.NORMAL}
    WIN[i+8] = {'fore': getattr(WinColor, color), 'style': WinStyle.BRIGHT}
    WIN[i+40] = {'back': getattr(WinColor, color)}

RESET = -1
ANSI[RESET] = "\033[0m"
WIN[RESET] =  {'reset': True}


def cprint(stream, *args, **kwds):
    """
    Print with color. Examples::

        # colors are BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
        cprint('stdout', RED, 'This is in red. ', RESET, 'and this is normal\n')

        # Adding BR_ before the color manes it bright
        cprint('stdout', BR_GREEN, 'This is bright green.\n', RESET)

        # Adding BACK_ changes background color
        cprint('stderr', BACK_BLUE, WHITE, 'This is white-on-blue.', -1)

        # Integers 0-7 for normal, 8-15 for bright, and 40-47 for background.
        # -1 to reset.
        cprint('stderr', 1, 'This is in red.', -1)

    """
    if isinstance(stream, basestring):
        stream = kwds.get('stream', 'stdout')
        err = stream == 'stderr'
        stream = getattr(sys, stream)
    else:
        err = kwds.get('stderr', False)

    if hasattr(stream, 'isatty') and stream.isatty():
        if _WIN:
            # convert to win32 calls
            for arg in args:
                if isinstance(arg, basestring):
                    stream.write(arg)
                else:
                    kwds = WIN[arg]
                    winset(stderr=err, **kwds)
        else:
            # convert to ANSI
            for arg in args:
                if isinstance(arg, basestring):
                    stream.write(arg)
                else:
                    stream.write(ANSI[arg])
    else:
        # ignore colors
        for arg in args:
            if isinstance(arg, basestring):
                stream.write(arg)

def cout(*args):
    """Shorthand for cprint('stdout', ...)"""
    cprint('stdout', *args)

def cerr(*args):
    """Shorthand for cprint('stderr', ...)"""
    cprint('stderr', *args)