Answer stability round 1: README's pick.go and datatype.go rows name what stayed, geo.py's options sort with each script's own, geo.py claims only shared steps, route defines fromRow as pathPos does, and disagreement's panic names the kinds

This commit is contained in:
2026-10-07 02:18:45 +02:00
committed by Lillem4n
parent ab8f375ae4
commit 2431edeab0
6 changed files with 12 additions and 16 deletions
+1 -3
View File
@@ -170,9 +170,7 @@ def streets(segments, codes, localities, per_locality):
def main():
p = geo.parser(__doc__, "SE")
p.add_argument("--key-file", help="file holding the Trafikverket API key; TRAFIKVERKET_API_KEY otherwise")
a = p.parse_args()
a = geo.parser(__doc__, "SE", key_file={"help": "file holding the Trafikverket API key; TRAFIKVERKET_API_KEY otherwise"}).parse_args()
key = Path(a.key_file).read_text().strip() if a.key_file else os.environ.get("TRAFIKVERKET_API_KEY")
if not key:
sys.exit("set TRAFIKVERKET_API_KEY or pass --key-file")
+1 -3
View File
@@ -154,9 +154,7 @@ def streets(cache, counties, locality_of_zcta, per_locality):
def main():
p = geo.parser(__doc__, "US")
p.add_argument("--min-population", type=int, default=25000)
a = p.parse_args()
a = geo.parser(__doc__, "US", min_population={"type": int, "default": 25000}).parse_args()
cache, out = geo.directories(a)
state_population = {r["STATE"]: r[ESTIMATE] for r in csv_rows(cache, STATES, "nst-est2025.csv") if r["SUMLEV"] == "040"}
+6 -6
View File
@@ -1,4 +1,4 @@
"""The steps every country's geo import takes."""
"""The steps a country's geo import may share with another's."""
import argparse
import collections
import math
@@ -9,12 +9,12 @@ DATA = Path(__file__).resolve().parent.parent / "data" / "geo"
CACHE = Path(__file__).resolve().parent / "cache"
def parser(doc, country):
"""The options every country's import takes; a script adds its own before parse_args."""
def parser(doc, country, **own):
"""The options every country's import takes and the script's own, keyed by name with "_" for "-", in name order."""
options = {"cache": {"default": str(CACHE)}, "out": {"default": str(DATA / country)}, "streets_per_locality": {"type": int, "default": 10}, **own}
p = argparse.ArgumentParser(description=doc.splitlines()[0])
p.add_argument("--cache", default=str(CACHE))
p.add_argument("--out", default=str(DATA / country))
p.add_argument("--streets-per-locality", type=int, default=10)
for name in sorted(options):
p.add_argument("--" + name.replace("_", "-"), **options[name])
return p