From b9f4223fd2e51af9110f584d63ee61f2c27c8205 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 19 Sep 2024 19:24:02 +0200 Subject: [PATCH] Continued: - an empty string is not the same as None, that's correct. So both need to be checked - yes, first I check on false (missing keys, etc.) then true (positive outcome) --- fba/http/network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fba/http/network.py b/fba/http/network.py index c982f61..6860001 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -388,8 +388,8 @@ def fetch_json_rows(hostname: str, path: str, headers: dict = {}, rows_key: str return list() elif "json" not in fetched: raise KeyError("fetched has no element 'json'") - elif rows_key != "" and rows_key not in fetched["json"]: - raise KeyError("fetched[row] has no element '{rows_key}'") + elif rows_key not in[None, ""] and rows_key not in fetched["json"]: + raise KeyError(f"fetched[row] has no element '{rows_key}'") elif rows_key == None: logger.debug("Parameter 'rows_key' is not set, using whole fetched['json'] as rows ...") rows = fetched["json"] -- 2.39.5