/usr/lib/python2.7/dist-packages/curtsies/termhelpers.py is in python-curtsies 0.2.6-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 | import tty
import termios
import fcntl
import os
class Nonblocking(object):
def __init__(self, stream):
self.stream = stream
self.fd = self.stream.fileno()
def __enter__(self):
self.orig_fl = fcntl.fcntl(self.fd, fcntl.F_GETFL)
fcntl.fcntl(self.fd, fcntl.F_SETFL, self.orig_fl | os.O_NONBLOCK)
def __exit__(self, *args):
fcntl.fcntl(self.fd, fcntl.F_SETFL, self.orig_fl)
class Cbreak(object):
def __init__(self, stream):
self.stream = stream
def __enter__(self):
self.original_stty = termios.tcgetattr(self.stream)
tty.setcbreak(self.stream, termios.TCSANOW)
return Termmode(self.stream, self.original_stty)
def __exit__(self, *args):
termios.tcsetattr(self.stream, termios.TCSANOW, self.original_stty)
class Termmode(object):
def __init__(self, stream, attrs):
self.stream = stream
self.attrs = attrs
def __enter__(self):
self.original_stty = termios.tcgetattr(self.stream)
termios.tcsetattr(self.stream, termios.TCSANOW, self.attrs)
def __exit__(self, *args):
termios.tcsetattr(self.stream, termios.TCSANOW, self.original_stty)
|