From 3d6ad04b3568f27b66952f5ab97282d49b85696e Mon Sep 17 00:00:00 2001 From: David McKee Date: Thu, 26 Sep 2024 15:36:17 +0100 Subject: [PATCH] make mandatory items mandatory --- src/ds_caselaw_utils/courts.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ds_caselaw_utils/courts.py b/src/ds_caselaw_utils/courts.py index 0892616..2407b0d 100644 --- a/src/ds_caselaw_utils/courts.py +++ b/src/ds_caselaw_utils/courts.py @@ -13,17 +13,17 @@ class Jurisdiction: def __init__(self, data) -> None: - self.code = data.get("code") - self.name = data.get("name") + self.code = data["code"] + self.name = data["name"] self.prefix = data.get("prefix") class Court: def __init__(self, data) -> None: - self.code = data.get("code") - self.name = data.get("name") - self.grouped_name = data.get("grouped_name") or data.get("name") - self.link = data.get("link") + self.code = data["code"] + self.name = data["name"] + self.grouped_name = data.get("grouped_name") or data["name"] + self.link = data["link"] self.ncn = data.get("ncn") self.canonical_param = data.get("param") self.param_aliases = [data.get("param")] + (data.get("extra_params") or []) @@ -112,7 +112,7 @@ def __init__(self, data) -> None: for courtData in group.get("courts"): court = Court(courtData) self._byParam[courtData.get("param")] = court - self._byCode[courtData.get("code")] = court + self._byCode[courtData["code"]] = court def get_by_param(self, param) -> Court: try: @@ -153,14 +153,14 @@ def get_selectable(self): courts = [] for category in self._data: for court in category.get("courts"): - if court.get("selectable"): + if court["selectable"]: courts.append(Court(court)) return courts def get_selectable_groups(self): groups = [] for category in self._data: - courts = [Court(court) for court in category.get("courts") if court.get("selectable")] + courts = [Court(court) for court in category.get("courts") if court["selectable"]] if len(courts) > 0: groups.append(CourtGroup(category.get("display_name"), courts)) return groups @@ -169,7 +169,7 @@ def get_grouped_selectable_courts(self): groups = [] for category in self._data: if not category.get("is_tribunal"): - courts = [Court(court) for court in category.get("courts") if court.get("selectable")] + courts = [Court(court) for court in category.get("courts") if court["selectable"]] if len(courts) > 0: groups.append(CourtGroup(category.get("display_name"), courts)) return groups @@ -178,7 +178,7 @@ def get_grouped_selectable_tribunals(self): groups = [] for category in self._data: if category.get("is_tribunal"): - courts = [Court(court) for court in category.get("courts") if court.get("selectable")] + courts = [Court(court) for court in category.get("courts") if court["selectable"]] if len(courts) > 0: groups.append(CourtGroup(category.get("display_name"), courts)) return groups @@ -186,7 +186,7 @@ def get_grouped_selectable_tribunals(self): def get_listable_groups(self): groups = [] for category in self._data: - courts = [Court(court) for court in category.get("courts") if court.get("listable")] + courts = [Court(court) for court in category.get("courts") if court["listable"]] if len(courts) > 0: groups.append(CourtGroup(category.get("display_name"), courts)) return groups @@ -196,7 +196,7 @@ def get_listable_courts(self): for group in self._data: if not group.get("is_tribunal"): for court in group.get("courts", []): - if court.get("listable"): + if court["listable"]: courts.append(Court(court)) return courts @@ -205,7 +205,7 @@ def get_listable_tribunals(self): for group in self._data: if group.get("is_tribunal"): for court in group.get("courts", []): - if court.get("listable"): + if court["listable"]: courts.append(Court(court)) return courts