Fetches a next line that ends either with \\r or \\n.
(self)
| 200 | return |
| 201 | |
| 202 | def nextline(self): |
| 203 | """Fetches a next line that ends either with \\r or \\n. |
| 204 | """ |
| 205 | linebuf = '' |
| 206 | linepos = self.bufpos + self.charpos |
| 207 | eol = False |
| 208 | while 1: |
| 209 | self.fillbuf() |
| 210 | if eol: |
| 211 | c = self.buf[self.charpos] |
| 212 | # handle '\r\n' |
| 213 | if c == '\n': |
| 214 | linebuf += c |
| 215 | self.charpos += 1 |
| 216 | break |
| 217 | m = EOL.search(self.buf, self.charpos) |
| 218 | if m: |
| 219 | linebuf += self.buf[self.charpos:m.end(0)] |
| 220 | self.charpos = m.end(0) |
| 221 | if linebuf[-1] == '\r': |
| 222 | eol = True |
| 223 | else: |
| 224 | break |
| 225 | else: |
| 226 | linebuf += self.buf[self.charpos:] |
| 227 | self.charpos = len(self.buf) |
| 228 | if 2 <= self.debug: |
| 229 | print >>sys.stderr, 'nextline: %r' % ((linepos, linebuf),) |
| 230 | return (linepos, linebuf) |
| 231 | |
| 232 | def revreadlines(self): |
| 233 | """Fetches a next line backword. |
no test coverage detected