Pull a single value from the stream, potentially reading some extra bytes from the underlying file-object. Returns `None` when reaching the end of the stream.
(self)
| 104 | self._current_bits = 0 |
| 105 | |
| 106 | def pull(self) -> tp.Optional[int]: |
| 107 | """ |
| 108 | Pull a single value from the stream, potentially reading some |
| 109 | extra bytes from the underlying file-object. |
| 110 | Returns `None` when reaching the end of the stream. |
| 111 | """ |
| 112 | while self._current_bits < self.bits: |
| 113 | buf = self.fo.read(1) |
| 114 | if not buf: |
| 115 | return None |
| 116 | character = buf[0] |
| 117 | self._current_value += character << self._current_bits |
| 118 | self._current_bits += 8 |
| 119 | |
| 120 | out = self._current_value & self._mask |
| 121 | self._current_value >>= self.bits |
| 122 | self._current_bits -= self.bits |
| 123 | return out |
| 124 | |
| 125 | |
| 126 | def test(): |