Skip to content

Commit

Permalink
make mandatory items mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Sep 26, 2024
1 parent 5306f9e commit 3d6ad04
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/ds_caselaw_utils/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [])
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -178,15 +178,15 @@ 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

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
Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 3d6ad04

Please sign in to comment.