From c210b72a3d6f528908aeccd2693c17e1ea3aabf5 Mon Sep 17 00:00:00 2001 From: ross-spencer Date: Thu, 15 Jan 2026 16:51:54 +0100 Subject: [PATCH 1/2] Improve use of HasPriority in PRONOM export --- src/jsonid/export.py | 3 ++- src/jsonid/pronom.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/jsonid/export.py b/src/jsonid/export.py index 7164a0c..c8d7371 100644 --- a/src/jsonid/export.py +++ b/src/jsonid/export.py @@ -21,6 +21,7 @@ PRONOM_FILENAME: Final[str] = "jsonid_pronom.xml" +JSON_PUID: Final[str] = "fmt/817" class PRONOMException(Exception): @@ -77,7 +78,7 @@ def export_pronom() -> None: increment_id += 1 fmt = pronom.Format( id=increment_id, - name=f"JSON (Baseline - fmt/817) ({encoding})", + name=f"JSON (Baseline - {JSON_PUID}) ({encoding})", version="", puid="jsonid:0000", mime="application/json", diff --git a/src/jsonid/pronom.py b/src/jsonid/pronom.py index 5a279df..64fc011 100644 --- a/src/jsonid/pronom.py +++ b/src/jsonid/pronom.py @@ -12,14 +12,15 @@ from typing import Any, Final try: + import export import export_helpers import helpers import registry_matchers except ModuleNotFoundError: try: - from src.jsonid import export_helpers, helpers, registry_matchers + from src.jsonid import export, export_helpers, helpers, registry_matchers except ModuleNotFoundError: - from jsonid import export_helpers, helpers, registry_matchers + from jsonid import export, export_helpers, helpers, registry_matchers logger = logging.getLogger(__name__) @@ -234,9 +235,19 @@ def create_file_format_collection(fmt: list[Format]): for sig in fmt.external_signatures if sig.type.lower() == EXT ] + + priority_ids = [] + for id_ in fmt.priorities: + if id_ == str(fmt.id): + continue + if export.JSON_PUID in fmt.name: + # This is brittle. Understand how to make more robust. + continue + priority_ids.append(id_) + priorities = [ f"{priority}" - for priority in fmt.priorities + for priority in priority_ids ] ff = f""" From 622eccc913f5868365f3fa0c2e20eec47304c3a8 Mon Sep 17 00:00:00 2001 From: ross-spencer Date: Thu, 15 Jan 2026 16:52:31 +0100 Subject: [PATCH 2/2] Add more PRONOM helpers --- justfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/justfile b/justfile index 9be2689..850a6a1 100644 --- a/justfile +++ b/justfile @@ -111,6 +111,10 @@ lookup-ref-ex: pronom: python jsonid.py --pronom --debug +# PRONOM demo +pronom-example: + python json2pronom.py -p pronom_example/patterns_example.json + # move pronom to .droid folder pronom-to-droid: ~/.droid6/clean.sh @@ -128,3 +132,7 @@ roy: droid-cli path: pronom-to-droid java -jar ~/dp/droid/droid-binary-6.8.0-bin/droid-command-line-6.8.0.jar -s 1 java -jar ~/dp/droid/droid-binary-6.8.0-bin/droid-command-line-6.8.0.jar -ri {{path}} + +# inspect prronom +inspect-pro: + bat jsonid_pronom.xml