File tree Expand file tree Collapse file tree 3 files changed +35
-34
lines changed Expand file tree Collapse file tree 3 files changed +35
-34
lines changed Original file line number Diff line number Diff line change 88import time
99from urllib .parse import quote
1010from utils import (
11+ facility_sheet_header ,
1112 logger ,
1213 session ,
1314)
1920WIKIPEDIA_DELAY = 0.5 # Be respectful to Wikipedia
2021WIKIDATA_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
5524class 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 (
Original file line number Diff line number Diff line change 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" : "" ,
Original file line number Diff line number Diff line change 2121default_timestamp = "1970-01-01T00:00:00-+0000"
2222timestamp_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
2557def _flatdict (d : dict , parent_key : str = "" , sep : str = "." ) -> dict :
2658 """flatten a nested dictionary for nicer printing in CSV"""
You can’t perform that action at this time.
0 commit comments