/usr/lib/python2.7/dist-packages/epsilon/liner.py is in python-epsilon 0.7.1-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 2005 Divmod, Inc. See LICENSE file for details
# -*- test-case-name: vertex.test.test_juice -*-
__metaclass__ = type
from twisted.internet.protocol import Protocol
class LineReceiver(Protocol):
lineMode = True
MAX_LINE_LENGTH = 1024 * 1024
buffer = ''
delimiter = '\r\n'
def lineReceived(self, line):
pass
def rawDataReceived(self, data):
pass
def setLineMode(self, extra=''):
self.lineMode = True
if extra:
self.dataReceived(extra)
def isDisconnecting(self):
if self.transport is None:
# XXX This _ought_ to be horribly broken but in fact it is
# not. TODO: Investigate further. -glyph
return False
if self.transport.disconnecting:
return True
return False
def setRawMode(self):
self.lineMode = False
def dataReceived(self, data):
buffer = self.buffer
buffer += data
delimiter = self.delimiter
begin = 0
raw = False
while self.lineMode:
end = buffer.find(delimiter, begin)
if end == -1:
break
line = buffer[begin:end]
self.lineReceived(line)
if self.isDisconnecting():
self.buffer = ''
return
begin = end + len(delimiter)
else:
raw = True
if begin:
buffer = buffer[begin:]
if raw:
self.buffer = ''
if self.isDisconnecting():
return
if buffer:
self.rawDataReceived(buffer)
else:
self.buffer = buffer
|