Let a place carry its own label and preposition, keep the count in every place title, and test that slugs follow names
A registry entry may now set label and prep. A plateau reads "Plateau" and "on the Colorado Plateau", the Mogollon Rim "Escarpment" and "along the Mogollon Rim", a national monument or a parkway its own word; the default is still "Mountain range" and "in the". Every national park, provincial park, monument, recreation area and parkway in the registry is labelled. A place title no longer gives up its ": N Trails" ending when it is long: it drops the state first and then keeps the count over the cap, and the state is left out where the name already holds it (Oregon Cascades, California Coast Ranges). A test checks that every slug is the slug of its display name, with the Arizona White Mountains as the one stated exception. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a97ea85093
commit
30d03b8069
10 files changed
+307
-43
No files matched your search
@@ -15,11 +15,12 @@ import tomllib
|
||||
|
||||
KINDS = ("park", "range", "wilderness")
|
||||
SOURCES = ("nps", "wilderness-connect", "cpcad", "gmba-v2")
|
||||
REGISTRY_KEYS = {"slug", "kind", "name", "where", "within", "source", "source_id",
|
||||
"source_version", "box"}
|
||||
REGISTRY_KEYS = {"slug", "kind", "name", "label", "prep", "where", "within", "source",
|
||||
"source_id", "source_version", "box"}
|
||||
REGISTRY_REQUIRED = ("slug", "kind", "name", "where", "source", "source_id",
|
||||
"source_version", "box")
|
||||
PLACE_KEYS = {"kind", "slug", "basis", "km", "source"}
|
||||
PREP_RE = re.compile(r"(in|on|at|along|across|near)( the)?")
|
||||
ID_RE = re.compile(r"[a-z0-9]+(-[a-z0-9]+)*")
|
||||
DATE_RE = re.compile(r"\d{4}-\d{2}-\d{2}")
|
||||
HASH_RE = re.compile(r"[0-9a-f]{16}")
|
||||
@@ -81,6 +82,11 @@ def check_registry(entries, errors):
|
||||
errors.append(f"{where} kind must be park, range or wilderness, not {kind!r}")
|
||||
if "name" in e:
|
||||
_text(e, "name", where, errors)
|
||||
if "label" in e:
|
||||
_text(e, "label", where, errors)
|
||||
if "prep" in e and not (isinstance(e["prep"], str) and PREP_RE.fullmatch(e["prep"])):
|
||||
errors.append(f"{where} prep must be a preposition such as \"in the\", \"on the\" "
|
||||
f"or \"along the\", not {e['prep']!r}")
|
||||
where_codes = e.get("where")
|
||||
if "where" in e and (not isinstance(where_codes, list) or not where_codes
|
||||
or not all(isinstance(c, str) and c for c in where_codes)):
|
||||
|
||||
Reference in new issue
Block a user