(self)
| 1865 | return self._cursor.next() |
| 1866 | |
| 1867 | def next(self) -> Mapping[str, Any]: |
| 1868 | try: |
| 1869 | chunk = self._next_with_retry() |
| 1870 | except StopIteration: |
| 1871 | if self._next_chunk >= self._num_chunks: |
| 1872 | raise |
| 1873 | raise CorruptGridFile("no chunk #%d" % self._next_chunk) from None |
| 1874 | |
| 1875 | if chunk["n"] != self._next_chunk: |
| 1876 | self.close() |
| 1877 | raise CorruptGridFile( |
| 1878 | "Missing chunk: expected chunk #%d but found " |
| 1879 | "chunk with n=%d" % (self._next_chunk, chunk["n"]) |
| 1880 | ) |
| 1881 | |
| 1882 | if chunk["n"] >= self._num_chunks: |
| 1883 | # According to spec, ignore extra chunks if they are empty. |
| 1884 | if len(chunk["data"]): |
| 1885 | self.close() |
| 1886 | raise CorruptGridFile( |
| 1887 | "Extra chunk found: expected %d chunks but found " |
| 1888 | "chunk with n=%d" % (self._num_chunks, chunk["n"]) |
| 1889 | ) |
| 1890 | |
| 1891 | expected_length = self.expected_chunk_length(chunk["n"]) |
| 1892 | if len(chunk["data"]) != expected_length: |
| 1893 | self.close() |
| 1894 | raise CorruptGridFile( |
| 1895 | "truncated chunk #%d: expected chunk length to be %d but " |
| 1896 | "found chunk with length %d" % (chunk["n"], expected_length, len(chunk["data"])) |
| 1897 | ) |
| 1898 | |
| 1899 | self._next_chunk += 1 |
| 1900 | return chunk |
| 1901 | |
| 1902 | __next__ = next |
| 1903 |
nothing calls this directly
no test coverage detected