This file is indexed.

/usr/lib/python3/dist-packages/bpython/simplerepl.py is in bpython3 0.15-2.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# encoding: utf-8

# The MIT License
#
# Copyright (c) 2015 the bpython authors.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""An example bpython repl without a nice UI for testing and to demonstrate
the methods of bpython.curtsiesrepl.repl.BaseRepl that must be overridden.
"""

from __future__ import unicode_literals, print_function, absolute_import

import time
import logging

from bpython.curtsiesfrontend.repl import BaseRepl
from bpython.curtsiesfrontend import events as bpythonevents
from bpython import translations
from bpython import importcompletion

from curtsies.configfile_keynames import keymap as key_dispatch


logger = logging.getLogger(__name__)


class SimpleRepl(BaseRepl):
    def __init__(self):
        self.requested_events = []
        BaseRepl.__init__(self)

    def _request_refresh(self):
        self.requested_events.append(bpythonevents.RefreshRequestEvent())

    def _schedule_refresh(self, when='now'):
        if when == 'now':
            self.request_refresh()
        else:
            dt = round(when - time.time(), 1)
            self.out('please refresh in {} seconds'.format(dt))

    def _request_reload(self, files_modified=('?',)):
        e = bpythonevents.ReloadEvent()
        e.files_modified = files_modified
        self.requested_events.append(e)
        self.out('please hit enter to trigger a refresh')

    def request_undo(self, n=1):
        self.requested_events.append(bpythonevents.UndoEvent(n=n))

    def out(self, msg):
        if hasattr(self, 'orig_stdout'):
            self.orig_stdout.write((msg + '\n').encode('utf8'))
            self.orig_stdout.flush()
        else:
            print(msg)

    def on_suspend(self):
        pass

    def after_suspend(self):
        self.out('please hit enter to trigger a refresh')

    def print_output(self):
        arr, cpos = self.paint()
        arr[cpos[0]:cpos[0] + 1, cpos[1]:cpos[1] + 1] = ['~']

        def print_padded(s):
            return self.out(s.center(self.width + 8, 'X'))

        print_padded('')
        print_padded(' enter -> "/", rewind -> "\\", ')
        print_padded(' reload -> "|", pastebin -> "$", ')
        print_padded(' "~" is the cursor ')
        print_padded('')
        self.out('X``' + ('`' * (self.width + 2)) + '``X')
        for line in arr:
            self.out('X```' + unicode(line.ljust(self.width)) + '```X')
        logger.debug('line:')
        logger.debug(repr(line))
        self.out('X``' + ('`' * (self.width + 2)) + '``X')
        self.out('X' * (self.width + 8))
        return max(len(arr) - self.height, 0)

    def get_input(self):
        chars = list(self.orig_stdin.readline()[:-1])
        while chars or self.requested_events:
            if self.requested_events:
                self.process_event(self.requested_events.pop())
                continue
            c = chars.pop(0)
            if c in '/':
                c = '\n'
            elif c in '\\':
                c = key_dispatch[self.config.undo_key][0]
            elif c in '$':
                c = key_dispatch[self.config.pastebin_key][0]
            elif c in '|':
                c = key_dispatch[self.config.reimport_key][0]
            self.process_event(c)


def main(args=None, locals_=None, banner=None):
    translations.init()
    while importcompletion.find_coroutine():
        pass
    with SimpleRepl() as r:
        r.width = 50
        r.height = 10
        while True:
            r.print_output()
            r.get_input()


if __name__ == '__main__':
    main()