Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ianare authored May 2, 2023
2 parents 988ed96 + e975fa6 commit dca9fce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: Static Analysis

on:
- push
- pull_request

jobs:
static-check:
Expand Down
1 change: 1 addition & 0 deletions exifread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _find_webp_exif(fh: BinaryIO) -> tuple:
if len(data) != 8:
raise InvalidExif("Invalid webp file chunk header.")
if data[0:4] == b'EXIF':
fh.seek(6, 1)
offset = fh.tell()
endian = fh.read(1)
return offset, endian
Expand Down
16 changes: 6 additions & 10 deletions exifread/heic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# gives us position and size information.

import struct
from typing import List, Dict, Callable, BinaryIO, Optional
from typing import Any, List, Dict, Callable, BinaryIO, Optional

from exifread.exif_log import get_logger

Expand All @@ -20,8 +20,6 @@

class WrongBox(Exception):
pass
class NoParser(Exception):
pass
class BoxVersion(Exception):
pass
class BadSize(Exception):
Expand Down Expand Up @@ -159,7 +157,7 @@ def expect_parse(self, name: str) -> Box:
return self.parse_box(box)
self.skip(box)

def get_parser(self, box: Box) -> Callable:
def get_parser(self, box: Box) -> Optional[Callable[[Box], Any]]:
defs = {
'ftyp': self._parse_ftyp,
'meta': self._parse_meta,
Expand All @@ -172,15 +170,13 @@ def get_parser(self, box: Box) -> Callable:
'idat': self._parse_idat, # HEIC/AVIF idat = Item Data Box
'dinf': self._parse_dinf, # HEIC/AVIF dinf = Data Information Box
'iprp': self._parse_iprp, # HEIC/AVIF iprp = Item Protection Box
}
try:
return defs[box.name]
except (IndexError, KeyError) as err:
raise NoParser(box.name) from err
}
return defs.get(box.name)

def parse_box(self, box: Box) -> Box:
probe = self.get_parser(box)
probe(box)
if probe is not None:
probe(box)
# in case anything is left unread
self.file_handle.seek(box.after)
return box
Expand Down

0 comments on commit dca9fce

Please sign in to comment.