소스 검색

match_against util: better indicate match failures

There was no distinction between dps missing that were optional,
and those that were required.  Output an extra message when
required dps are missing in addition to noting them as missing.
Make the mismatch failures stand out better by putting key
reason for the mismatch in all caps and ending with !!!
Jason Rumney 2 년 전
부모
커밋
20335a0973
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      util/match_against.py

+ 6 - 2
util/match_against.py

@@ -24,9 +24,11 @@ def main() -> int:
     for dp in config.primary_entity.dps():
         if dp.id not in dps.keys():
             print(f"    {dp.name} missing from data")
+            if not dp.optional:
+                print(f"      dp {dp.id} is REQUIRED!!!!")
         elif not _typematch(dp.type, dps.get(dp.id)):
             print(
-                f"    {dp.name} type mismatch, expected {dp.type.__name__}, got {dps.get(dp.id)}"
+                f"    {dp.name} type MISMATCH, expected {dp.type.__name__}, got {dps.get(dp.id)}!!!"
             )
         else:
             print(f"   {dp.name}: {dp.get_value(device)} from {dp.values(device)}")
@@ -35,9 +37,11 @@ def main() -> int:
         for dp in entity.dps():
             if dp.id not in dps.keys():
                 print(f"    {dp.name} missing from data")
+                if not dp.optional:
+                    print(f"      dp {dp.id} is REQUIRED!!!!")
             elif not _typematch(dp.type, dps.get(dp.id)):
                 print(
-                    f"    {dp.name} type mismatch, expected {dp.type.__name__}, got {dps.get(dp.id)}"
+                    f"    {dp.name} type MISMATCH, expected {dp.type.__name__}, got {dps.get(dp.id)}!!!"
                 )
             else:
                 print(f"    {dp.name}: {dp.get_value(device)}")