Skip to content

Commit 652fdae

Browse files
author
Dmytro Trotsko
committed
Added exception for non-existing indicator sets
1 parent aecab33 commit 652fdae

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/indicators/resources.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ def process_pathogens(row) -> None:
6363

6464

6565
def process_indicator_set(row) -> None:
66+
indicator_set_id = None
6667
if row["Indicator Set"]:
6768
indicator_set_name = row["Indicator Set"].strip()
68-
indicator_set_obj = IndicatorSet.objects.get(
69-
name=indicator_set_name
70-
)
71-
if indicator_set_obj:
72-
row["Indicator Set"] = indicator_set_obj.id
73-
else:
74-
row["Indicator Set"] = None
69+
try:
70+
indicator_set_obj = IndicatorSet.objects.get(
71+
name=indicator_set_name
72+
)
73+
indicator_set_id = indicator_set_obj.id
74+
except IndicatorSet.DoesNotExist:
75+
logger.warning(f"Indicator Set '{indicator_set_name}' not found.")
76+
row["Indicator Set"] = indicator_set_id
77+
7578

7679

7780
def process_indicator_type(row) -> None:

0 commit comments

Comments
 (0)