Skip to content

Commit 0177974

Browse files
authored
Merge pull request #53 from johnseekins/jtf-fix match two JTF records
match two JTF records
2 parents f63dfe9 + dd1fe1e commit 0177974

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

ice_scrapers/__init__.py

Lines changed: 5 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.",
@@ -127,6 +131,7 @@
127131
repair_locality, # noqa: F401
128132
repair_street, # noqa: F401
129133
repair_zip, # noqa: F401
134+
special_facilities, # noqa: F401
130135
update_facility, # noqa: F401
131136
)
132137
from .facilities_scraper import scrape_facilities # noqa: F401,E402

ice_scrapers/facilities_scraper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
repair_locality,
88
repair_street,
99
repair_zip,
10+
special_facilities,
1011
update_facility,
1112
)
1213
from schemas import facility_schema
@@ -37,6 +38,7 @@ def scrape_facilities(facilities_data: dict) -> dict:
3738
logger.debug("Found %s facilities on page %s", len(facilities), page_num + 1)
3839
time.sleep(1) # Be respectful to the server
3940
for facility in facilities:
41+
facility = special_facilities(facility)
4042
addr = facility["address"]
4143
street, cleaned = repair_street(addr["street"], addr["locality"])
4244
if cleaned:

ice_scrapers/spreadsheet_load.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
repair_locality,
1616
repair_street,
1717
repair_zip,
18+
special_facilities,
1819
)
1920
from typing import Tuple
2021
from utils import (
@@ -94,12 +95,20 @@ def load_sheet(keep_sheet: bool = True) -> dict:
9495
locality, cleaned = repair_locality(row["City"], row["State"])
9596
if cleaned:
9697
details["_repaired_record"] = True
97-
full_address = ",".join([street, locality, row["State"], zcode]).upper()
9898
details["address"]["administrative_area"] = row["State"]
9999
details["address"]["locality"] = locality
100100
details["address"]["postal_code"] = zcode
101101
details["address"]["street"] = street
102102
details["name"] = row["Name"]
103+
details = special_facilities(details)
104+
full_address = ",".join(
105+
[
106+
details["address"]["street"],
107+
details["address"]["locality"],
108+
details["address"]["administrative_area"],
109+
details["address"]["postal_code"],
110+
]
111+
).upper()
103112

104113
"""
105114
population statistics

ice_scrapers/utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@
77
)
88

99

10+
def special_facilities(facility: dict) -> dict:
11+
"""
12+
Some very specific facilities have unique fixes
13+
that are hard to fit into our normal repair_* pattern.
14+
15+
Please don't expand this function unless it's necessary
16+
"""
17+
match facility["name"]:
18+
case "Naval Station Guantanamo Bay (JTF Camp Six and Migrant Ops Center Main A)":
19+
"""
20+
First special case? JTF Camp Six is purely a mess.
21+
While we work on getting a consistent address for this facility,
22+
we'll need to make the two records converge.
23+
"""
24+
facility["address"]["country"] = "Cuba"
25+
facility["address"]["administrative_area"] = "FPO"
26+
facility["address"]["locality"] = "FPO"
27+
facility["address"]["postal_code"] = "34009"
28+
facility["address"]["street"] = "AVENUE C PSC 1005 BOX 55"
29+
case "JTF CAMP SIX":
30+
facility["address"]["country"] = "Cuba"
31+
facility["address"]["administrative_area"] = "FPO"
32+
facility["name"] = "Naval Station Guantanamo Bay (JTF Camp Six and Migrant Ops Center Main A)"
33+
case _:
34+
pass
35+
return facility
36+
37+
1038
def repair_street(street: str, locality: str = "") -> Tuple[str, bool]:
1139
"""Generally, we'll let the spreadsheet win arguments just to be consistent"""
1240
street_filters = [

0 commit comments

Comments
 (0)