From b1d6ab6751898f7c088d58229ab6a7185094133c Mon Sep 17 00:00:00 2001 From: James Frost Date: Fri, 23 Aug 2024 16:15:50 +0100 Subject: [PATCH] Add workaround for old python not supporting ISO 8601 datetimes This should be removed when we drop python 3.10 support. --- src/CSET/_workflow_utils/fetch_data.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CSET/_workflow_utils/fetch_data.py b/src/CSET/_workflow_utils/fetch_data.py index 1beee8c9f..4a83519ee 100755 --- a/src/CSET/_workflow_utils/fetch_data.py +++ b/src/CSET/_workflow_utils/fetch_data.py @@ -7,6 +7,7 @@ import logging import os import shutil +import sys from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timedelta from typing import Literal @@ -85,6 +86,10 @@ def get_file(self, file_path: str, output_dir: str) -> None: def _get_needed_environment_variables() -> dict: """Load the needed variables from the environment.""" + # Python 3.10 and older don't fully support ISO 8601 datetime formats. + # TODO: Remove once we drop python 3.10. + if sys.version_info.minor < 11: + datetime.fromisoformat = isodate.parse_datetime variables = { "raw_path": os.environ["DATA_PATH"], "date_type": os.environ["DATE_TYPE"],