MCPcopy Index your code
hub / github.com/plotly/plotly.py / _iter_straight_packed

Method _iter_straight_packed

_plotly_utils/png.py:1557–1584  ·  view source on GitHub ↗

Iterator that undoes the effect of filtering; yields each row as a sequence of packed bytes. Assumes input is straightlaced. `byte_blocks` should be an iterable that yields the raw bytes in blocks of arbitrary size.

(self, byte_blocks)

Source from the content-addressed store, hash-verified

1555 return out[:width]
1556
1557 def _iter_straight_packed(self, byte_blocks):
1558 """Iterator that undoes the effect of filtering;
1559 yields each row as a sequence of packed bytes.
1560 Assumes input is straightlaced.
1561 `byte_blocks` should be an iterable that yields the raw bytes
1562 in blocks of arbitrary size.
1563 """
1564
1565 # length of row, in bytes
1566 rb = self.row_bytes
1567 a = bytearray()
1568 # The previous (reconstructed) scanline.
1569 # None indicates first line of image.
1570 recon = None
1571 for some_bytes in byte_blocks:
1572 a.extend(some_bytes)
1573 while len(a) >= rb + 1:
1574 filter_type = a[0]
1575 scanline = a[1 : rb + 1]
1576 del a[: rb + 1]
1577 recon = self.undo_filter(filter_type, scanline, recon)
1578 yield recon
1579 if len(a) != 0:
1580 # :file:format We get here with a file format error:
1581 # when the available bytes (after decompressing) do not
1582 # pack into exact rows.
1583 raise FormatError("Wrong size for decompressed IDAT chunk.")
1584 assert len(a) == 0
1585
1586 def validate_signature(self):
1587 """

Callers 1

readMethod · 0.95

Calls 3

undo_filterMethod · 0.95
FormatErrorClass · 0.85
extendMethod · 0.45

Tested by

no test coverage detected