From de9f3da43d41c9ed8157030b7751562e4e9ee81b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 23 Mar 2022 03:45:26 -0400 Subject: [PATCH] [21] fixes for f1 --- VERSION | 2 +- modules/ergast.py | 2 +- modules/util.py | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index d561566a..3c9f90e5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.2-develop20 +1.16.2-develop21 diff --git a/modules/ergast.py b/modules/ergast.py index 21eb1302..a59ec94f 100644 --- a/modules/ergast.py +++ b/modules/ergast.py @@ -70,7 +70,7 @@ class Race: def format_name(self, round_prefix, shorten_gp): if self._language: output = f"GP {self.name.replace(' Grand Prix', '')}" if shorten_gp else self.name - for eng_value, trans_value in translations[self._language]: + for eng_value, trans_value in translations[self._language].items(): output = output.replace(eng_value, trans_value) else: output = self.name.replace("Grand Prix", "GP") if shorten_gp else self.name diff --git a/modules/util.py b/modules/util.py index 1febd4a4..bd0a2ac9 100644 --- a/modules/util.py +++ b/modules/util.py @@ -133,8 +133,13 @@ def get_int_list(data, id_type): return int_values def validate_date(date_text, method, return_as=None): - try: date_obg = datetime.strptime(str(date_text), "%Y-%m-%d" if "-" in str(date_text) else "%m/%d/%Y") - except ValueError: raise Failed(f"Collection Error: {method}: {date_text} must match pattern YYYY-MM-DD (e.g. 2020-12-25) or MM/DD/YYYY (e.g. 12/25/2020)") + if isinstance(date_text, datetime): + date_obg = date_text + else: + try: + date_obg = datetime.strptime(str(date_text), "%Y-%m-%d" if "-" in str(date_text) else "%m/%d/%Y") + except ValueError: + raise Failed(f"Collection Error: {method}: {date_text} must match pattern YYYY-MM-DD (e.g. 2020-12-25) or MM/DD/YYYY (e.g. 12/25/2020)") return datetime.strftime(date_obg, return_as) if return_as else date_obg def logger_input(prompt, timeout=60):