From 044a03ddf9d8f92a275e17448c81d8a0e2fde5af Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Tue, 5 Mar 2024 15:43:00 +0100
Subject: [PATCH] Fix up filenames in formatscaper results

---
 formatscaper/formatscaper.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/formatscaper/formatscaper.py b/formatscaper/formatscaper.py
index 7840737..3b0f99c 100755
--- a/formatscaper/formatscaper.py
+++ b/formatscaper/formatscaper.py
@@ -221,11 +221,16 @@ def process_record_file(record_file: RecordFile) -> None:
                         if match["ns"] == "pronom":
                             format = Format.from_sf_dict(match)
 
+                            # replace first occurrence of the URI with filename
+                            filename = file_info["filename"].replace(
+                                record_file.uri, record_file.filename, 1
+                            )
+
                             # the storing of results needs to be mutually exclusive
                             with mutex:
                                 format = formats.setdefault(format.puid, format)
                                 result = Result(
-                                    filename=file_info["filename"],
+                                    filename=filename,
                                     record=record_file.record,
                                     format=format,
                                 )
-- 
GitLab