diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 08:58:29 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 08:58:29 +0100 |
commit | ba6329bbe14c832d42773dee2fe30bd7669ca255 (patch) | |
tree | 4cd2771d95adaba0663fd7879b1666ebd3ef3cb9 /bsie | |
parent | 70d77819a84c73292825b81f952e162bb30753d7 (diff) | |
download | bsie-ba6329bbe14c832d42773dee2fe30bd7669ca255.tar.gz bsie-ba6329bbe14c832d42773dee2fe30bd7669ca255.tar.bz2 bsie-ba6329bbe14c832d42773dee2fe30bd7669ca255.zip |
various minor fixes
Diffstat (limited to 'bsie')
-rw-r--r-- | bsie/apps/__init__.py | 2 | ||||
-rw-r--r-- | bsie/apps/_loader.py | 4 | ||||
-rw-r--r-- | bsie/extractor/image/photometrics.py | 37 |
3 files changed, 20 insertions, 23 deletions
diff --git a/bsie/apps/__init__.py b/bsie/apps/__init__.py index cec8f84..2fe4795 100644 --- a/bsie/apps/__init__.py +++ b/bsie/apps/__init__.py @@ -33,7 +33,7 @@ def main(argv=None): parser = argparse.ArgumentParser(description=main.__doc__, prog='bsie') # version parser.add_argument('--version', action='version', - version='%(prog)s version {}.{}.{}'.format(*bsie.version_info)) + version='%(prog)s version {}.{}.{}'.format(*bsie.version_info)) # pylint: disable=C0209 # application selection parser.add_argument('app', choices=apps.keys(), help='Select the application to run.') diff --git a/bsie/apps/_loader.py b/bsie/apps/_loader.py index 36dd8a6..6411f10 100644 --- a/bsie/apps/_loader.py +++ b/bsie/apps/_loader.py @@ -16,8 +16,8 @@ DEFAULT_CONFIG_FILE = 'default_config.yaml' # exports __all__: typing.Sequence[str] = ( - 'load', 'DEFAULT_CONFIG_FILE', + 'load_pipeline', ) @@ -26,7 +26,7 @@ __all__: typing.Sequence[str] = ( def load_pipeline(path: str) -> Pipeline: """Load a pipeline according to a config at *path*.""" # load config file - with open(path, 'rt') as ifile: + with open(path, 'rt', encoding='utf-8') as ifile: cfg = yaml.safe_load(ifile) # reader builder diff --git a/bsie/extractor/image/photometrics.py b/bsie/extractor/image/photometrics.py index 525f207..c5254ab 100644 --- a/bsie/extractor/image/photometrics.py +++ b/bsie/extractor/image/photometrics.py @@ -20,7 +20,7 @@ __all__: typing.Sequence[str] = ( def _gps_to_dec(coords: typing.Tuple[float, float, float]) -> float: """Convert GPS coordinates from exif to float.""" # unpack args - deg, min, sec = coords + deg, min, sec = coords # pylint: disable=redefined-builtin # min # convert to float deg = float(Fraction(deg)) min = float(Fraction(min)) @@ -29,9 +29,8 @@ def _gps_to_dec(coords: typing.Tuple[float, float, float]) -> float: if float(sec) > 0: # format is deg+min+sec return (float(deg) * 3600 + float(min) * 60 + float(sec)) / 3600 - else: - # format is deg+min - return float(deg) + float(min) / 60 + # format is deg+min + return float(deg) + float(min) / 60 class Exif(base.Extractor): @@ -124,20 +123,19 @@ class Exif(base.Extractor): # produce triple yield subject, pred, value - def _date(self, content: dict): # FIXME: Return type annotation - raise NotImplementedError() - #date_keys = ( - # 'Exif.Photo.DateTimeOriginal', - # 'Exif.Photo.DateTimeDigitized', - # 'Exif.Image.DateTime', - # ) - #for key in date_keys: - # if key in content: - # dt = content[key].value - # if dt.tzinfo is None: - # dt = dt.replace(tzinfo=ttime.NoTimeZone) - # return dt - #return None + #def _date(self, content: dict): # FIXME: Return type annotation + # date_keys = ( + # 'Exif.Photo.DateTimeOriginal', + # 'Exif.Photo.DateTimeDigitized', + # 'Exif.Image.DateTime', + # ) + # for key in date_keys: + # if key in content: + # dt = content[key].value + # if dt.tzinfo is None: + # dt = dt.replace(tzinfo=ttime.NoTimeZone) + # return dt + # return None ## photometrics @@ -189,8 +187,7 @@ class Exif(base.Extractor): if width is not None and height is not None and ori is not None: if ori <= 4: return 'landscape' if width >= height else 'portrait' - else: - return 'portrait' if width >= height else 'landscape' + return 'portrait' if width >= height else 'landscape' return None |