Add sourced day counts, seasons and permit notes, and record why short trails are listed

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-19 11:07:15 -07:00
1 parent d00df3b8ee
commit 007ff5fb77
58 files changed
+825 -84

No files matched your search

+28
View File
@@ -466,6 +466,30 @@ def _whole_km(value):
return isinstance(value, int) and not isinstance(value, bool) and value > 0
SHORT_FLOOR_KM = 80 # 50 miles: the inclusion floor in README.md
UNDER_REVIEW = "Listed before the test was written; under review."
def check_short_reason(tid, rec, errors, warnings=None):
"""short_reason (docs/schema.md): the one sentence saying why a trail under the floor is listed.
Required on every record whose length_km is under SHORT_FLOOR_KM and refused on any other. The
sentence UNDER_REVIEW is accepted, as a warning, for a record whose own text supports none of
the owner's three tests; the owner decides whether it stays."""
length = rec.get("length_km")
reason = rec.get("short_reason")
short = isinstance(length, (int, float)) and not isinstance(length, bool) and length < SHORT_FLOOR_KM
if reason is not None and not (isinstance(reason, str) and reason.strip()):
errors.append(f"{tid}: short_reason must be a non-empty sentence")
elif short and reason is None:
errors.append(f"{tid}: length_km {length} is under the {SHORT_FLOOR_KM} km floor, so "
"short_reason must say why it is listed")
elif not short and reason is not None:
errors.append(f"{tid}: short_reason is only for a trail under {SHORT_FLOOR_KM} km")
elif short and reason.strip() == UNDER_REVIEW and warnings is not None:
warnings.append(f"{tid}: under {SHORT_FLOOR_KM} km and no reason for listing it is supported yet")
def check_held_note(tid, rec, errors):
"""A held record says why in wave_note: the page quotes it, and says nothing when there is none."""
if str(rec.get("wave", "")) == "held" and not str(rec.get("wave_note", "")).strip():
@@ -738,6 +762,7 @@ def check_left_out(root, trails, errors):
def main():
errors = []
warnings = []
trail_ids = build_index.trail_dirs(ROOT)
if not trail_ids:
print("no trail directories found")
@@ -761,6 +786,7 @@ def main():
check_common_name(tid, rec, errors)
check_length_facts(tid, rec, errors)
check_held_note(tid, rec, errors)
check_short_reason(tid, rec, errors, warnings)
if rec.get("id") != tid:
errors.append(f"{tid}: id {rec.get('id')!r} does not match directory name")
if rec.get("country") not in ("US", "CA"):
@@ -917,6 +943,8 @@ def main():
except FileNotFoundError as e:
errors.append(f"generated file missing ({e.filename}): run python3 tools/build_index.py")
for w in warnings:
print(f"WARN {w}")
if errors:
for e in errors:
print(f"ERROR {e}")