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

Method revreadlines

pattern/web/pdf/psparser.py:232–254  ·  view source on GitHub ↗

Fetches a next line backword. This is used to locate the trailers at the end of a file.

(self)

Source from the content-addressed store, hash-verified

230 return (linepos, linebuf)
231
232 def revreadlines(self):
233 """Fetches a next line backword.
234
235 This is used to locate the trailers at the end of a file.
236 """
237 self.fp.seek(0, 2)
238 pos = self.fp.tell()
239 buf = ''
240 while 0 < pos:
241 prevpos = pos
242 pos = max(0, pos-self.BUFSIZ)
243 self.fp.seek(pos)
244 s = self.fp.read(prevpos-pos)
245 if not s: break
246 while 1:
247 n = max(s.rfind('\r'), s.rfind('\n'))
248 if n == -1:
249 buf = s + buf
250 break
251 yield s[n:]+buf
252 s = s[:n]
253 buf = ''
254 return
255
256 def _parse_main(self, s, i):
257 m = NONSPC.search(s, i)

Callers 1

find_xrefMethod · 0.80

Calls 3

tellMethod · 0.80
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected