From de71ab3f5047a935a880fa5adee20f29eb6438cc Mon Sep 17 00:00:00 2001 From: rosepearson Date: Tue, 3 Sep 2024 16:03:59 +1200 Subject: [PATCH] Fix typo --- src/geoapis/raster.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/geoapis/raster.py b/src/geoapis/raster.py index 477e9f4..a340aaf 100644 --- a/src/geoapis/raster.py +++ b/src/geoapis/raster.py @@ -149,12 +149,13 @@ def run(self, layer: int) -> pathlib.Path: url=f"{self.base_url}/exports/", headers=headers, json=api_query ) json_query = response.json() - if not json_query["is_valid"]: - logging.warning( - "Invalid initial query. Check layer exists and is within bounds. " - f"json_query['invalid_reasons']: {json_query['invalid_reasons']}. " - f"json_query['items'][0]['invalid_reasons']: {json_query['items'][0]['invalid_reasons']}" - ) + if "is_valid" in json_query.keys() and not json_query["is_valid"]: + message = f"Invalid initial query. Check layer {layer} exists and is within bounds." + if "invalid_reasons" in json_query.keys(): + message = message + f" json_query['invalid_reasons']: {json_query['invalid_reasons']}." + if "items" in json_query.keys(): + message = message + f" json_query['items'][0]['invalid_reasons']: {json_query['items'][0]['invalid_reasons']}" + logging.warning(message) return [] query_id = json_query["id"]