From affc2ba953244d6b2ee99119b61a59b8ee0ac345 Mon Sep 17 00:00:00 2001 From: Stasinos Konstantopoulos Date: Tue, 22 Oct 2024 12:24:08 +0300 Subject: [PATCH] Avoid exception handling --- src/sigal/utils.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/sigal/utils.py b/src/sigal/utils.py index 80ee3c9..a2da3c3 100644 --- a/src/sigal/utils.py +++ b/src/sigal/utils.py @@ -137,18 +137,12 @@ def read_markdown(filename): pass else: output["meta"] = meta - try: - output["title"] = MD.Meta["title"][0] - except KeyError: - pass - try: - output["lat"] = MD.Meta["lat"][0] - except KeyError: - pass - try: - output["lon"] = MD.Meta["lon"][0] - except KeyError: - pass + l = MD.Meta.get("title", []) + if l: output["title"] = l[0] + l = MD.Meta.get("lat", []) + if l: output["lat"] = l[0] + l = MD.Meta.get("lon", []) + if l: output["lon"] = l[0] return output