This file is indexed.

/usr/lib/python2.7/dist-packages/cogent/util/terminal.py is in python-cogent 1.9-9.

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
#!/usr/bin/env python

__author__ = "Nadia Alramli"
__copyright__ = "Copyright 2007-2016, The Cogent Project"
__credits__ = ["Nadia Alramli"]
__license__ = "BSD"
__version__ = "1.9"
__maintainer__ = "Peter Maxwell"
__email__ = "pm67nz@gmail.com"
__status__ = "Production"

# Copyright: 2008 Nadia Alramli
# License: BSD

import sys
try:
    import curses
except ImportError:
    curses = None

COLORS = "BLUE GREEN CYAN RED MAGENTA YELLOW WHITE BLACK".split()

# List of terminal controls, you can add more to the list.
_CONTROLS = {
    'BOL':'cr', 'UP':'cuu1', 'DOWN':'cud1', 'LEFT':'cub1', 'RIGHT':'cuf1',
    'CLEAR_SCREEN':'clear', 'CLEAR_EOL':'el', 'CLEAR_BOL':'el1',
    'CLEAR_EOS':'ed', 'BOLD':'bold', 'BLINK':'blink', 'DIM':'dim',
    'REVERSE':'rev', 'UNDERLINE':'smul', 'NORMAL':'sgr0',
    'HIDE_CURSOR':'cinvis', 'SHOW_CURSOR':'cnorm'
        }

class TerminalUnavailableError(RuntimeError):
    pass
    
class CursesOutput(object):
    def __init__(self):
        if curses is None:
            raise TerminalUnavailableError("No curses modules")
        elif not hasattr(sys.stdout, 'fileno'):
            raise TerminalUnavailableError("stdout not a real file")
        try:
            curses.setupterm()
        except (curses.error, IOError), detail:
            raise TerminalUnavailableError(detail)
    
    def getColumns(self):
        return curses.tigetnum('cols')
    
    def getLines(self):
        return curses.tigetnum('lines')
    
    def getCodes(self):
        # Get the color escape sequence template or '' if not supported
        # setab and setaf are for ANSI escape sequences
        bgColorSeq = curses.tigetstr('setab') or curses.tigetstr('setb') or ''
        fgColorSeq = curses.tigetstr('setaf') or curses.tigetstr('setf') or ''
        codes = {}
        
        for color in COLORS:
            # Get the color index from curses
            colorIndex = getattr(curses, 'COLOR_%s' % color)
            # Set the color escape sequence after filling the template with index
            for (prefix, termseq) in [('', fgColorSeq), ('BG_', bgColorSeq)]:
                key = prefix + color
                try:
                    codes[key] = curses.tparm(termseq, colorIndex)
                except curses.error:
                    codes[key] = ''
        
        for control in _CONTROLS:
            # Set the control escape sequence
            codes[control] = curses.tigetstr(_CONTROLS[control]) or ''
        
        return codes