mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-23 15:20:33 +03:00
Merge pull request #8709 from radarhere/seek
This commit is contained in:
commit
793e1fcba2
|
@ -10,6 +10,7 @@
|
||||||
#
|
#
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
|
@ -40,13 +41,11 @@ class BufrStubImageFile(ImageFile.StubImageFile):
|
||||||
format_description = "BUFR"
|
format_description = "BUFR"
|
||||||
|
|
||||||
def _open(self) -> None:
|
def _open(self) -> None:
|
||||||
offset = self.fp.tell()
|
|
||||||
|
|
||||||
if not _accept(self.fp.read(4)):
|
if not _accept(self.fp.read(4)):
|
||||||
msg = "Not a BUFR file"
|
msg = "Not a BUFR file"
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
self.fp.seek(offset)
|
self.fp.seek(-4, os.SEEK_CUR)
|
||||||
|
|
||||||
# make something up
|
# make something up
|
||||||
self._mode = "F"
|
self._mode = "F"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#
|
#
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
|
@ -40,13 +41,11 @@ class GribStubImageFile(ImageFile.StubImageFile):
|
||||||
format_description = "GRIB"
|
format_description = "GRIB"
|
||||||
|
|
||||||
def _open(self) -> None:
|
def _open(self) -> None:
|
||||||
offset = self.fp.tell()
|
|
||||||
|
|
||||||
if not _accept(self.fp.read(8)):
|
if not _accept(self.fp.read(8)):
|
||||||
msg = "Not a GRIB file"
|
msg = "Not a GRIB file"
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
self.fp.seek(offset)
|
self.fp.seek(-8, os.SEEK_CUR)
|
||||||
|
|
||||||
# make something up
|
# make something up
|
||||||
self._mode = "F"
|
self._mode = "F"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#
|
#
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
|
@ -40,13 +41,11 @@ class HDF5StubImageFile(ImageFile.StubImageFile):
|
||||||
format_description = "HDF5"
|
format_description = "HDF5"
|
||||||
|
|
||||||
def _open(self) -> None:
|
def _open(self) -> None:
|
||||||
offset = self.fp.tell()
|
|
||||||
|
|
||||||
if not _accept(self.fp.read(8)):
|
if not _accept(self.fp.read(8)):
|
||||||
msg = "Not an HDF file"
|
msg = "Not an HDF file"
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
self.fp.seek(offset)
|
self.fp.seek(-8, os.SEEK_CUR)
|
||||||
|
|
||||||
# make something up
|
# make something up
|
||||||
self._mode = "F"
|
self._mode = "F"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user