From 5f8d8873b311348ced29a0d4119fb3b9c361128d Mon Sep 17 00:00:00 2001 From: caribaud Date: Sat, 27 May 2023 16:08:58 +0200 Subject: [PATCH] Warn about floating height/width and round them Closes #8 --- zooms_generator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zooms_generator.py b/zooms_generator.py index e886218..c9d7241 100644 --- a/zooms_generator.py +++ b/zooms_generator.py @@ -40,8 +40,12 @@ def extract_zooms(src_folder): tree = ET.parse(svg_path) root = tree.getroot() - zooms[idx]["width"] = int(root.get("width")) - zooms[idx]["height"] = int(root.get("height")) + if "." in root.get("width"): + print(f"WARNING: file {svg_path} has a floating width, it will be rounded", file=sys.stderr) + zooms[idx]["width"] = round(float(root.get("width"))) + if "." in root.get("height"): + print(f"WARNING: file {svg_path} has a floating height, it will be rounded", file=sys.stderr) + zooms[idx]["height"] = round(float(root.get("height"))) for area in root.findall('.//{*}rect'): zooms[idx]["zooms"].append([