| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  | import json | 
					
						
							| 
									
										
										
										
											2024-12-27 15:07:55 -05:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  | import pkgutil | 
					
						
							| 
									
										
										
										
											2024-12-27 15:07:55 -05:00
										 |  |  | from datetime import datetime | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | def load_data_file(*args) -> dict: | 
					
						
							| 
									
										
										
										
											2024-12-08 19:59:40 -05:00
										 |  |  |     fname = "/".join(["data", *args]) | 
					
						
							| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  |     return json.loads(pkgutil.get_data(__name__, fname).decode()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-27 15:07:55 -05:00
										 |  |  | def relative_years_from_today(dt2: datetime) -> int: | 
					
						
							|  |  |  |     today = datetime.now() | 
					
						
							|  |  |  |     years = today.year - dt2.year | 
					
						
							|  |  |  |     if today.month < dt2.month or (today.month == dt2.month and today.day < dt2.day): | 
					
						
							|  |  |  |         years -= 1 | 
					
						
							|  |  |  |     return years | 
					
						
							| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-27 15:07:55 -05:00
										 |  |  | location_id_offset: int = 27000 | 
					
						
							|  |  |  | location_info = load_data_file("locations.json") | 
					
						
							|  |  |  | location_name_to_id = {name: location_id_offset + index for index, name in enumerate(location_info["all_locations"])} | 
					
						
							|  |  |  | exclusion_info = load_data_file("excluded_locations.json") | 
					
						
							| 
									
										
										
										
											2023-11-24 16:23:45 -07:00
										 |  |  | region_info = load_data_file("regions.json") | 
					
						
							| 
									
										
										
										
											2024-12-27 15:07:55 -05:00
										 |  |  | years_since_sep_30_1980 = relative_years_from_today(datetime.fromisoformat("1980-09-30")) |