MCPcopy Index your code
hub / github.com/python-openxml/python-docx / next

Method next

src/docx/image/jpeg.py:167–187  ·  view source on GitHub ↗

Return a (marker_code, segment_offset) 2-tuple identifying and locating the first marker in `stream` occuring after offset `start`. The returned `segment_offset` points to the position immediately following the 2-byte marker code, the start of the marker segment, for those m

(self, start)

Source from the content-addressed store, hash-verified

165 return cls(stream)
166
167 def next(self, start):
168 """Return a (marker_code, segment_offset) 2-tuple identifying and locating the
169 first marker in `stream` occuring after offset `start`.
170
171 The returned `segment_offset` points to the position immediately following the
172 2-byte marker code, the start of the marker segment, for those markers that have
173 a segment.
174 """
175 position = start
176 while True:
177 # skip over any non-\xFF bytes
178 position = self._offset_of_next_ff_byte(start=position)
179 # skip over any \xFF padding bytes
180 position, byte_ = self._next_non_ff_byte(start=position + 1)
181 # 'FF 00' sequence is not a marker, start over if found
182 if byte_ == b"\x00":
183 continue
184 # this is a marker, gather return values and break out of scan
185 marker_code, segment_offset = byte_, position + 1
186 break
187 return marker_code, segment_offset
188
189 def _next_non_ff_byte(self, start):
190 """Return an offset, byte 2-tuple for the next byte in `stream` that is not

Calls 2

_next_non_ff_byteMethod · 0.95