MCPcopy Create free account
hub / github.com/ActiveState/code / readline

Method readline

recipes/Python/173071_ReseekFile/recipe-173071.py:78–94  ·  view source on GitHub ↗

read a line from the file

(self)

Source from the content-addressed store, hash-verified

76 return x
77
78 def readline(self):
79 """read a line from the file"""
80
81 # Can we get it out of the buffer_file?
82 s = self.buffer_file.readline()
83 if s[-1:] == "\n":
84 return s
85 # No, so now we read a line from the input file
86 t = self.file.readline()
87
88 # Append the new data to the buffer, if still buffering
89 if self._use_buffer:
90 self.buffer_file.write(t)
91
92 self._check_no_buffer()
93
94 return s + t
95
96 def readlines(self):
97 """read all remaining lines from the file"""

Callers 4

convertMethod · 0.45
__init__Method · 0.45
__call__Method · 0.45
recipe-157035.pyFile · 0.45

Calls 2

_check_no_bufferMethod · 0.95
writeMethod · 0.45

Tested by

no test coverage detected