Kaynağa Gözat

check_descriptors.py: allow checking specific models, not just all

Common case while iterating on one driver is checking just that panel; full
registry scan stays the default so cross-project drift checks (e.g. after a
vendor bump) are unchanged.
ZiB 2 hafta önce
ebeveyn
işleme
13bf1f3f10
1 değiştirilmiş dosya ile 22 ekleme ve 3 silme
  1. 22 3
      tools/check_descriptors.py

+ 22 - 3
tools/check_descriptors.py

@@ -12,8 +12,10 @@ Catches two things: an emitter regression (reproduction breaks), and GxEPD2
 upstream drift (a vendor bump changes a driver -> its panel now differs ->
 review it). Exit non-zero on any unexpected mismatch.
 
-    tools/check_descriptors.py          # check all
-    tools/check_descriptors.py -v       # show the diff on a mismatch
+    tools/check_descriptors.py                    # check all
+    tools/check_descriptors.py -v                 # show the diff on a mismatch
+    tools/check_descriptors.py GxEPD2_154_Z90c     # check just one (or more) models
+    tools/check_descriptors.py GxEPD2_154_Z90c GxEPD2_270
 
 Panels the emitter does not yet fully model (dual-region, see KNOWN_DIFF) are
 expected to differ and don't fail; if one of them starts MATCHING, that's an
@@ -23,6 +25,7 @@ source (e.g. the synthetic MASTER_ONLY variant) are skipped.
 
 import argparse
 import ast
+import difflib
 import pathlib
 import re
 import sys
@@ -114,12 +117,28 @@ def check(model: str, catalog: dict, verbose: bool) -> str:
 
 def main() -> None:
     ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+    ap.add_argument("models", nargs="*", help="only check these registry keys (default: check every registered panel)")
     ap.add_argument("-v", "--verbose", action="store_true", help="show the fields that differ on a mismatch")
     args = ap.parse_args()
 
+    all_models = list(registry())
+    if args.models:
+        unknown = [m for m in args.models if m not in all_models]
+        if unknown:
+            for m in unknown:
+                hint = difflib.get_close_matches(m, all_models, n=3)
+                msg = f"not in display.py's PANELS: {m}"
+                if hint:
+                    msg += "\ndid you mean: " + ", ".join(hint)
+                print(msg, file=sys.stderr)
+            sys.exit(1)
+        models = args.models
+    else:
+        models = all_models
+
     catalog = cap.load_catalog()
     results = {}
-    for model in registry():
+    for model in models:
         # capture.py prints its own [capture] line to stderr; keep output tidy.
         res = check(model, catalog, args.verbose)
         results[model] = res