From 7c006c4a835a75ef51c45f93e401cc837e874817 Mon Sep 17 00:00:00 2001
From: Stefan Bienert <stefan.bienert@unibas.ch>
Date: Thu, 10 Aug 2023 14:31:11 +0200
Subject: [PATCH] Add 'errors' to report

---
 validation/validate-mmcif-file.py | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/validation/validate-mmcif-file.py b/validation/validate-mmcif-file.py
index 91b17f2..e3e4d0a 100755
--- a/validation/validate-mmcif-file.py
+++ b/validation/validate-mmcif-file.py
@@ -709,13 +709,6 @@ class _CifCheck:
 
         Be aware, that cuts away the majority of the messages. But solving those
         issues first, may already repair a mmCIF file."""
-        not_implemented = ["errors"]
-        for category in not_implemented:
-            if len(self.check_results[category]) > 0:
-                raise NotImplementedError(
-                    f"Results for category '{category}' not yet supported in "
-                    + "report."
-                )
         print("Report")
         print("======")
         print(f"Status of check: {self.check_results['status']}")
@@ -814,6 +807,30 @@ class _CifCheck:
             for line in sorted(rprt["parchild_mm"]):
                 print(f"      {line}")
 
+        # condense 'other' errors
+        rprt = {
+            "missing_files": {},
+        }
+        for line in self.check_results["errors"]:
+            match = re.match(r"ma_entry_associated_files.file_url '(?P<arc>.*)' is missing ma_associated_archive_file_details.file_path '(?P<fle>.*)'", line)
+            if match is not None:
+                try:
+                    rprt["missing_files"][match.group('arc')].append(match.group('fle'))
+                except KeyError:
+                    rprt["missing_files"][match.group('arc')] = [match.group('fle')]
+                continue
+            # Unmatched lines need to be added to above evaluation
+            raise RuntimeError(f'Unmatched error line found:\n"""{line}"""')
+
+        # print above evaluation in the report
+        print("Other issues:")
+        if len(rprt["missing_files"]) > 0:
+            print("   Missing (archive) )files:")
+            for arc, fles in rprt["missing_files"].items():
+                print(f"      {arc}:")
+                for line in fles:
+                    print(f"         {line}")
+
         # print erros/ messages caught
         print("Errors by running CifCheck:")
         for line in self.check_results["cifcheck-errors"]:
-- 
GitLab