瀏覽代碼

feat(util/match_against): report differences in both direction

When comparing two configs, or logs against a specific config, missing
dps and type mismatches were reported, but extra dps were not. To get
extra dps reported, you needed to run one of the other matching utilities.

Add reporting of extra dps so that one utility is enough to get a full picture
of compatibility.
Jason Rumney 11 小時之前
父節點
當前提交
96376aa5ca
共有 1 個文件被更改,包括 6 次插入 和 1 次删除
  1. 6 1
      util/match_against.py

+ 6 - 1
util/match_against.py

@@ -15,14 +15,17 @@ def main() -> int:
         dps = json.loads(rest)
     else:
         dps = make_sample_dps(config)
-    device = FakeDevice(dps)
+
     config = load_config(sys.argv[1])
     if config is None:
         print(f"No config could be loaded for {sys.argv[1]}")
         return 1
+    device = FakeDevice(dps)
+    unseen = set(dps.keys())
     for entity in config.all_entities():
         print(f"{entity.config_id}:")
         for dp in entity.dps():
+            unseen.discard(dp.id)
             if dp.id not in dps.keys():
                 print(f"   {dp.name} missing from data")
                 if not dp.optional:
@@ -38,6 +41,8 @@ def main() -> int:
                 else:
                     values = ""
                 print(f"   {dp.name}: {dp.get_value(device)}{values}")
+    for dp in unseen:
+        print(f"   Extra dp {dp} in data")
 
 
 if __name__ == "__main__":