begin take action page

This commit is contained in:
chrisbell committed 2026-11-22 13:23:26 -06:00
1 parent e3e291b8cf
commit 1c38a7bdb0
75 files changed
+496 -1

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""One-off: create data/counties/<slug>.yaml for all 67 Alabama counties.
Alabama county FIPS codes are the odd numbers 001..133 in alphabetical order,
so they can be computed. Run from the repo root: python scripts/make_county_stubs.py
Existing files are never overwritten, so it is safe to re-run.
"""
from pathlib import Path
import yaml
# Same regions as the Discord bot's data.py
REGIONS = {
"North": "Lauderdale, Colbert, Franklin, Marion, Lamar, Madison, Limestone, Morgan, "
"Lawrence, Cullman, Winston, Jackson, Marshall, DeKalb, Cherokee, Etowah",
"West": "Bibb, Choctaw, Fayette, Greene, Hale, Marengo, Pickens, Sumter, Tuscaloosa, Perry",
"South": "Mobile, Baldwin, Houston, Dale, Coffee, Geneva, Henry, Covington, Escambia, "
"Conecuh, Monroe, Clarke, Washington, Pike, Barbour, Butler, Crenshaw, Wilcox",
"Central": "Jefferson, Shelby, Saint Clair, Blount, Walker, Montgomery, Autauga, Elmore, "
"Chilton, Dallas, Lowndes",
"East": "Lee, Russell, Chambers, Tallapoosa, Randolph, Macon, Calhoun, Cleburne, Clay, "
"Talladega, Coosa, Bullock",
}
region_of = {
name.strip(): region
for region, names in REGIONS.items()
for name in names.split(",")
}
assert len(region_of) == 67, len(region_of)
out = Path("data/counties")
out.mkdir(parents=True, exist_ok=True)
for i, name in enumerate(sorted(region_of)):
slug = name.lower().replace(" ", "-")
record = {
"name": name,
"slug": slug,
"fips": f"01{2 * i + 1:03d}",
"region": region_of[name],
}
if name == "DeKalb":
assert record["fips"] == "01049" # sanity check on the numbering
path = out / f"{slug}.yaml"
if not path.exists():
path.write_text(yaml.safe_dump(record, sort_keys=False), encoding="utf-8")
print(f"{len(list(out.glob('*.yaml')))} county files in {out}/")