MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _read

Method _read

lib/matplotlib/dviread.py:331–376  ·  view source on GitHub ↗

Read one page from the file. Return True if successful, False if there were no more pages.

(self)

Source from the content-addressed store, hash-verified

329 height=(maxy_pure-miny)*d, descent=descent)
330
331 def _read(self):
332 """
333 Read one page from the file. Return True if successful,
334 False if there were no more pages.
335 """
336 # Pages appear to start with the sequence
337 # bop (begin of page)
338 # xxx comment
339 # <push, ..., pop> # if using chemformula
340 # down
341 # push
342 # down
343 # <push, push, xxx, right, xxx, pop, pop> # if using xcolor
344 # down
345 # push
346 # down (possibly multiple)
347 # push <= here, v is the baseline position.
348 # etc.
349 # (dviasm is useful to explore this structure.)
350 # Thus, we use the vertical position at the first time the stack depth
351 # reaches 3, while at least three "downs" have been executed (excluding
352 # those popped out (corresponding to the chemformula preamble)), as the
353 # baseline (the "down" count is necessary to handle xcolor).
354 down_stack = [0]
355 self._baseline_v = None
356 while True:
357 byte = self.file.read(1)[0]
358 self._dtable[byte](self, byte)
359 if self._missing_font:
360 raise self._missing_font.to_exception()
361 name = self._dtable[byte].__name__
362 if name == "_push":
363 down_stack.append(down_stack[-1])
364 elif name == "_pop":
365 down_stack.pop()
366 elif name == "_down":
367 down_stack[-1] += 1
368 if (self._baseline_v is None
369 and len(getattr(self, "stack", [])) == 3
370 and down_stack[-1] >= 4):
371 self._baseline_v = self.v
372 if byte == 140: # end of page
373 return True
374 if self.state is _dvistate.post_post: # end of file
375 self.close()
376 return False
377
378 def _read_arg(self, nbytes, signed=False):
379 """

Callers 1

__iter__Method · 0.95

Calls 3

closeMethod · 0.95
to_exceptionMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected