From fae9ce4e5dc3c291499e7838c0aafbe8dd0c8952 Mon Sep 17 00:00:00 2001 From: Jean-Marie PLACE Date: Thu, 14 Jul 2022 09:50:15 +0200 Subject: [PATCH] fix null resilution bug --- app/scodoc/sco_logos.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_logos.py b/app/scodoc/sco_logos.py index 343c4c46..278cccb9 100644 --- a/app/scodoc/sco_logos.py +++ b/app/scodoc/sco_logos.py @@ -136,7 +136,9 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX): if os.access(path_dir.joinpath(entry).absolute(), os.R_OK): result = filename_parser.match(entry.name) if result: - logoname = result.group(1)[:-1] # retreive logoname from filename (less final dot) + logoname = result.group(1)[ + :-1 + ] # retreive logoname from filename (less final dot) logos[logoname] = Logo(logoname=logoname, dept_id=dept_id).select() return logos if len(logos.keys()) > 0 else None @@ -235,7 +237,7 @@ class Logo: unit = img.info.get("jfif_unit", 0) # 0 = no unit ; 1 = inch ; 2 = mm if self.density is not None: x_density, y_density = self.density - if unit != 0: + if unit != 0 and x_density != 0 and y_density != 0: unit2mm = [0, 1 / 0.254, 0.1][unit] x_mm = round(x_size * unit2mm / x_density, 2) y_mm = round(y_size * unit2mm / y_density, 2) @@ -244,7 +246,6 @@ class Logo: self.mm = None else: self.mm = None - self.size = (x_size, y_size) self.aspect_ratio = round(float(x_size) / y_size, 2)