Skip to content

Commit 94b83d3

Browse files
committed
match two JTF records
Signed-off-by: John Seekins <[email protected]>
1 parent f63dfe9 commit 94b83d3

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

ice_scrapers/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"expanded_name": "Dedicated Intergovernmental Service Agreement",
5454
"description": "A publicly-owned facility operated by state/local government(s), or private contractors, in which ICE contracts to use all bed space via a Dedicated Intergovernmental Service Agreement; or facilities used by ICE pursuant to Intergovernmental Service Agreements, which house only ICE detainees – typically these are operated by private contractors pursuant to their agreements with local governments.",
5555
},
56+
"DOD": {
57+
"expanded_name": "Department of Defense",
58+
"description": "Military facility",
59+
},
5660
"IGSA": {
5761
"expanded_name": "Intergovernmental Service Agreement",
5862
"description": "A publicly-owned facility operated by state/local government(s), or private contractors, in which ICE contracts for bed space via an Intergovernmental Service Agreement; or local jails used by ICE pursuant to Intergovernmental Service Agreements, which house both ICE and non-ICE detainees, typically county prisoners awaiting trial or serving short sentences, but sometimes also USMS prisoners.",

ice_scrapers/facilities_scraper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
base_scrape_url = "https://www.ice.gov/detention-facilities"
2222

2323

24+
def _special_facilities(facility: dict) -> dict:
25+
match facility["name"]:
26+
case "Naval Station Guantanamo Bay (JTF Camp Six and Migrant Ops Center Main A)":
27+
facility["address"]["country"] = "Cuba"
28+
facility["address"]["administrative_area"] = "FPO"
29+
facility["address"]["locality"] = "FPO"
30+
facility["address"]["postal_code"] = "34009"
31+
facility["address"]["street"] = "AVENUE C PSC 1005 BOX 55"
32+
case _:
33+
pass
34+
return facility
35+
36+
2437
def scrape_facilities(facilities_data: dict) -> dict:
2538
"""Scrape all ICE detention facility data from all discovered pages"""
2639
start_time = time.time()
@@ -37,6 +50,7 @@ def scrape_facilities(facilities_data: dict) -> dict:
3750
logger.debug("Found %s facilities on page %s", len(facilities), page_num + 1)
3851
time.sleep(1) # Be respectful to the server
3952
for facility in facilities:
53+
facility = _special_facilities(facility)
4054
addr = facility["address"]
4155
street, cleaned = repair_street(addr["street"], addr["locality"])
4256
if cleaned:

ice_scrapers/spreadsheet_load.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def _download_sheet(keep_sheet: bool = True) -> Tuple[polars.DataFrame, str]:
7272
return df, actual_link
7373

7474

75+
def _special_rows(row: dict) -> dict:
76+
match row["name"]:
77+
case "JTF CAMP SIX":
78+
row["address"]["country"] = "Cuba"
79+
row["address"]["administrative_area"] = "FPO"
80+
row["name"] = "Naval Station Guantanamo Bay (JTF Camp Six and Migrant Ops Center Main A)"
81+
case _:
82+
pass
83+
return row
84+
85+
7586
def load_sheet(keep_sheet: bool = True) -> dict:
7687
df, sheet_url = _download_sheet(keep_sheet)
7788
"""Convert the detentionstats sheet data into something we can update our facilities with"""
@@ -94,12 +105,20 @@ def load_sheet(keep_sheet: bool = True) -> dict:
94105
locality, cleaned = repair_locality(row["City"], row["State"])
95106
if cleaned:
96107
details["_repaired_record"] = True
97-
full_address = ",".join([street, locality, row["State"], zcode]).upper()
98108
details["address"]["administrative_area"] = row["State"]
99109
details["address"]["locality"] = locality
100110
details["address"]["postal_code"] = zcode
101111
details["address"]["street"] = street
102112
details["name"] = row["Name"]
113+
details = _special_rows(details)
114+
full_address = ",".join(
115+
[
116+
details["address"]["street"],
117+
details["address"]["locality"],
118+
details["address"]["administrative_area"],
119+
details["address"]["postal_code"],
120+
]
121+
).upper()
103122

104123
"""
105124
population statistics

0 commit comments

Comments
 (0)