MCPcopy Index your code
hub / github.com/clips/pattern / nextline

Method nextline

pattern/web/pdf/psparser.py:202–230  ·  view source on GitHub ↗

Fetches a next line that ends either with \\r or \\n.

(self)

Source from the content-addressed store, hash-verified

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.

Callers 4

loadMethod · 0.80
load_fallbackMethod · 0.80
do_keywordMethod · 0.80
read_xref_fromMethod · 0.80

Calls 3

fillbufMethod · 0.95
lenFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected