@@ -49,12 +49,13 @@ def special_facilities(facility: dict) -> dict:
4949 facility ["address" ]["country" ] = "Cuba"
5050 facility ["address" ]["administrative_area" ] = "FPO"
5151 facility ["name" ] = "Naval Station Guantanamo Bay (JTF Camp Six and Migrant Ops Center Main A)"
52+ facility ["other_names" ] = ["JTF CAMP SIX" ]
5253 case _:
5354 pass
5455 return facility
5556
5657
57- def repair_name (name : str , locality : str ) -> tuple [str , bool ]:
58+ def repair_name (name : str , locality : str ) -> tuple [str , bool , list [ str ] ]:
5859 """Even facility names are occasionally bad"""
5960 matches = [
6061 {"match" : "ALEXANDRIA STAGING FACILI" , "replace" : "Alexandria Staging Facility" , "locality" : "ALEXANDRIA" },
@@ -107,15 +108,17 @@ def repair_name(name: str, locality: str) -> tuple[str, bool]:
107108 },
108109 ]
109110 cleaned = False
111+ other_names = []
110112 for m in matches :
111113 if m ["match" ] == name and m ["locality" ] == locality :
114+ other_names = [m ["match" ]]
112115 name = m ["replace" ]
113116 cleaned = True
114117 break
115- return name , cleaned
118+ return name , cleaned , other_names
116119
117120
118- def repair_street (street : str , locality : str = "" ) -> tuple [str , bool ]:
121+ def repair_street (street : str , locality : str = "" ) -> tuple [str , bool , list [ str ] ]:
119122 """Generally, we'll let the spreadsheet win arguments just to be consistent"""
120123 street_filters = [
121124 # address mismatch between site and spreadsheet
@@ -218,8 +221,10 @@ def repair_street(street: str, locality: str = "") -> tuple[str, bool]:
218221 # default matches should come last
219222 ]
220223 cleaned = False
224+ other_streets = []
221225 for f in street_filters :
222226 if (f ["match" ] in street ) and ((f ["locality" ] and f ["locality" ] == locality ) or not f ["locality" ]):
227+ other_streets = [f ["match" ]]
223228 street = street .replace (f ["match" ], f ["replace" ])
224229 cleaned = True
225230 break
@@ -233,22 +238,24 @@ def repair_street(street: str, locality: str = "") -> tuple[str, bool]:
233238 if f ["match" ] in street :
234239 street = street .replace (f ["match" ], f ["replace" ])
235240 cleaned = True
236- return street , cleaned
241+ return street , cleaned , other_streets
237242
238243
239- def repair_zip (zip_code : int , locality : str ) -> tuple [str , bool ]:
244+ def repair_zip (zip_code : int , locality : str ) -> tuple [str , bool , list [ str ] ]:
240245 """
241246 Excel does a cool thing where it strips leading 0s
242247 Also, many zip codes are mysteriously discordant
243248 """
249+ other_zips = []
244250 zcode = str (zip_code )
245251 cleaned = False
246252 # don't replace an empty zip with all 0s
247253 if 0 < len (zcode ) < 5 :
254+ other_zips = [zcode ]
248255 # pad any prefix
249256 zeros = "0" * (5 - len (zcode ))
250257 zcode = f"{ zeros } { zcode } "
251- return zcode , cleaned
258+ return zcode , cleaned , other_zips
252259 matches = [
253260 {"match" : "89512" , "replace" : "89506" , "locality" : "Reno" },
254261 {"match" : "82901" , "replace" : "82935" , "locality" : "Rock Springs" },
@@ -261,18 +268,20 @@ def repair_zip(zip_code: int, locality: str) -> tuple[str, bool]:
261268 ]
262269 for z in matches :
263270 if z ["match" ] == zcode and z ["locality" ] == locality :
271+ other_zips = [z ["match" ]]
264272 zcode = z ["replace" ]
265273 cleaned = True
266274 break
267- return zcode , cleaned
275+ return zcode , cleaned , other_zips
268276
269277
270- def repair_locality (locality : str , administrative_area : str ) -> tuple [str , bool ]:
278+ def repair_locality (locality : str , administrative_area : str ) -> tuple [str , bool , list [ str ] ]:
271279 """
272280 There is no consistency with any address.
273281 How the post office ever successfully delivered a letter is beyond me
274282 """
275283 cleaned = False
284+ other_city = []
276285 matches = [
277286 {"match" : "LaGrange" , "replace" : "La Grange" , "area" : "KY" },
278287 {"match" : "Leachfield" , "replace" : "LEITCHFIELD" , "area" : "KY" },
@@ -282,10 +291,11 @@ def repair_locality(locality: str, administrative_area: str) -> tuple[str, bool]
282291 ]
283292 for f in matches :
284293 if f ["match" ] == locality and f ["area" ] == administrative_area :
294+ other_city = [f ["match" ]]
285295 locality = f ["replace" ]
286296 cleaned = True
287297 break
288- return locality , cleaned
298+ return locality , cleaned , other_city
289299
290300
291301def update_facility (old : dict , new : dict ) -> dict :
0 commit comments