in azure/datalake/store/core.py [0:0]
def readline(self, length=-1):
"""
Read and return a line from the stream.
If length is specified, at most size bytes will be read.
"""
if length < 0:
length = self.size
line = b""
while True:
# if cache has last bytes of file and its read, return line and exit loop
if self.end >= self.size and self.loc >= self.end:
return line
self._read_blocksize()
found = self.cache[self.loc - self.start:].find(b'\n') + 1
if found:
partialLine = self.cache[
self.loc - self.start: min(self.loc - self.start + found, self.loc - self.start + length)]
else:
partialLine = self.cache[self.loc - self.start:]
self.loc += len(partialLine)
line += partialLine
if found:
return line