Skip to content

Commit 00855ca

Browse files
committed
correct types and move large const into utils
Signed-off-by: John Seekins <[email protected]>
1 parent d21af02 commit 00855ca

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

enricher.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import time
99
from urllib.parse import quote
1010
from utils import (
11+
facility_sheet_header,
1112
logger,
1213
session,
1314
)
@@ -19,38 +20,6 @@
1920
WIKIPEDIA_DELAY = 0.5 # Be respectful to Wikipedia
2021
WIKIDATA_DELAY = 0.5 # Be respectful to Wikidata
2122

22-
# extracted ADP sheet header list 2025-09-07
23-
facility_sheet_header = [
24-
"Name",
25-
"Address",
26-
"City",
27-
"State",
28-
"Zip",
29-
"AOR",
30-
"Type Detailed",
31-
"Male/Female",
32-
"FY25 ALOS",
33-
"Level A",
34-
"Level B",
35-
"Level C",
36-
"Level D",
37-
"Male Crim",
38-
"Male Non-Crim",
39-
"Female Crim",
40-
"Female Non-Crim",
41-
"ICE Threat Level 1",
42-
"ICE Threat Level 2",
43-
"ICE Threat Level 3",
44-
"No ICE Threat Level",
45-
"Mandatory",
46-
"Guaranteed Minimum",
47-
"Last Inspection Type",
48-
"Last Inspection End Date",
49-
"Pending FY25 Inspection",
50-
"Last Inspection Standard",
51-
"Last Final Rating",
52-
]
53-
5423

5524
class ExternalDataEnricher(object):
5625
def __init__(self):
@@ -67,7 +36,7 @@ def _download_sheet(self) -> None:
6736
if chunk:
6837
f.write(chunk)
6938

70-
def _load_sheet(self) -> polars.DataFrame:
39+
def _load_sheet(self) -> dict:
7140
"""Convert the detentionstats sheet data into something we can update our facilities with"""
7241
self._download_sheet()
7342
df = polars.read_excel(

schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
# default keys to "false"-y values so we can merge easier
11-
facility_schema = {
11+
facility_schema: dict = {
1212
"address": {
1313
"administrative_area": "",
1414
"country": "",

utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,38 @@
2121
default_timestamp = "1970-01-01T00:00:00-+0000"
2222
timestamp_format = "%Y-%m-%dT%H:%M:%S-%z"
2323

24+
# extracted ADP sheet header list 2025-09-07
25+
facility_sheet_header = [
26+
"Name",
27+
"Address",
28+
"City",
29+
"State",
30+
"Zip",
31+
"AOR",
32+
"Type Detailed",
33+
"Male/Female",
34+
"FY25 ALOS",
35+
"Level A",
36+
"Level B",
37+
"Level C",
38+
"Level D",
39+
"Male Crim",
40+
"Male Non-Crim",
41+
"Female Crim",
42+
"Female Non-Crim",
43+
"ICE Threat Level 1",
44+
"ICE Threat Level 2",
45+
"ICE Threat Level 3",
46+
"No ICE Threat Level",
47+
"Mandatory",
48+
"Guaranteed Minimum",
49+
"Last Inspection Type",
50+
"Last Inspection End Date",
51+
"Pending FY25 Inspection",
52+
"Last Inspection Standard",
53+
"Last Final Rating",
54+
]
55+
2456

2557
def _flatdict(d: dict, parent_key: str = "", sep: str = ".") -> dict:
2658
"""flatten a nested dictionary for nicer printing in CSV"""

0 commit comments

Comments
 (0)