Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
96 lines
4.4 KiB
Python
96 lines
4.4 KiB
Python
"""
|
|
State adapter registry.
|
|
|
|
Maps 2-letter state codes to their adapter modules.
|
|
Each state directory contains:
|
|
- config.py — Portal URLs, NW RA address, selectors, fees
|
|
- adapter.py — StatePortal subclass with Playwright automation
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from scripts.formation.base import StatePortal
|
|
|
|
# State metadata for the registry
|
|
STATES = {
|
|
"AL": {"name": "Alabama", "search_method": "playwright"},
|
|
"AK": {"name": "Alaska", "search_method": "socrata"},
|
|
"AZ": {"name": "Arizona", "search_method": "playwright"},
|
|
"AR": {"name": "Arkansas", "search_method": "playwright"},
|
|
"CA": {"name": "California", "search_method": "playwright"},
|
|
"CO": {"name": "Colorado", "search_method": "socrata_api"},
|
|
"CT": {"name": "Connecticut", "search_method": "socrata"},
|
|
"DE": {"name": "Delaware", "search_method": "playwright"},
|
|
"FL": {"name": "Florida", "search_method": "sftp_bulk"},
|
|
"GA": {"name": "Georgia", "search_method": "playwright"},
|
|
"HI": {"name": "Hawaii", "search_method": "playwright"},
|
|
"ID": {"name": "Idaho", "search_method": "playwright"},
|
|
"IL": {"name": "Illinois", "search_method": "socrata"},
|
|
"IN": {"name": "Indiana", "search_method": "playwright"},
|
|
"IA": {"name": "Iowa", "search_method": "socrata"},
|
|
"KS": {"name": "Kansas", "search_method": "playwright"},
|
|
"KY": {"name": "Kentucky", "search_method": "playwright"},
|
|
"LA": {"name": "Louisiana", "search_method": "playwright"},
|
|
"ME": {"name": "Maine", "search_method": "playwright"},
|
|
"MD": {"name": "Maryland", "search_method": "playwright"},
|
|
"MA": {"name": "Massachusetts", "search_method": "playwright"},
|
|
"MI": {"name": "Michigan", "search_method": "socrata"},
|
|
"MN": {"name": "Minnesota", "search_method": "playwright"},
|
|
"MS": {"name": "Mississippi", "search_method": "playwright"},
|
|
"MO": {"name": "Missouri", "search_method": "playwright"},
|
|
"MT": {"name": "Montana", "search_method": "playwright"},
|
|
"NE": {"name": "Nebraska", "search_method": "playwright"},
|
|
"NV": {"name": "Nevada", "search_method": "playwright"},
|
|
"NH": {"name": "New Hampshire", "search_method": "playwright"},
|
|
"NJ": {"name": "New Jersey", "search_method": "playwright"},
|
|
"NM": {"name": "New Mexico", "search_method": "playwright"},
|
|
"NY": {"name": "New York", "search_method": "socrata"},
|
|
"NC": {"name": "North Carolina", "search_method": "playwright"},
|
|
"ND": {"name": "North Dakota", "search_method": "playwright"},
|
|
"OH": {"name": "Ohio", "search_method": "playwright"},
|
|
"OK": {"name": "Oklahoma", "search_method": "playwright"},
|
|
"OR": {"name": "Oregon", "search_method": "socrata"},
|
|
"PA": {"name": "Pennsylvania", "search_method": "socrata"},
|
|
"RI": {"name": "Rhode Island", "search_method": "playwright"},
|
|
"SC": {"name": "South Carolina", "search_method": "playwright"},
|
|
"SD": {"name": "South Dakota", "search_method": "playwright"},
|
|
"TN": {"name": "Tennessee", "search_method": "playwright"},
|
|
"TX": {"name": "Texas", "search_method": "playwright"},
|
|
"UT": {"name": "Utah", "search_method": "playwright"},
|
|
"VT": {"name": "Vermont", "search_method": "socrata"},
|
|
"VA": {"name": "Virginia", "search_method": "playwright"},
|
|
"WA": {"name": "Washington", "search_method": "socrata"},
|
|
"WV": {"name": "West Virginia", "search_method": "playwright"},
|
|
"WI": {"name": "Wisconsin", "search_method": "playwright"},
|
|
"WY": {"name": "Wyoming", "search_method": "playwright"},
|
|
"DC": {"name": "District of Columbia", "search_method": "playwright"},
|
|
# Canadian provinces
|
|
"BC": {"name": "British Columbia", "search_method": "playwright"},
|
|
"ON": {"name": "Ontario", "search_method": "playwright"},
|
|
}
|
|
|
|
|
|
def get_adapter(state_code: str) -> "StatePortal":
|
|
"""Dynamically import and return the adapter for a state."""
|
|
code = state_code.upper()
|
|
if code not in STATES:
|
|
raise ValueError(f"Unknown state code: {code}")
|
|
|
|
module_name = f".{code.lower()}.adapter"
|
|
import importlib
|
|
mod = importlib.import_module(module_name, package=__name__)
|
|
return mod.adapter()
|
|
|
|
|
|
def get_config(state_code: str) -> dict:
|
|
"""Return the config dict for a state."""
|
|
code = state_code.upper()
|
|
if code not in STATES:
|
|
raise ValueError(f"Unknown state code: {code}")
|
|
|
|
module_name = f".{code.lower()}.config"
|
|
import importlib
|
|
mod = importlib.import_module(module_name, package=__name__)
|
|
return mod.CONFIG
|