From 70dc7b85be71ffde9705862f06d5a9f02c9fccd7 Mon Sep 17 00:00:00 2001 From: Melissa Draper Date: Tue, 25 Aug 2026 16:27:02 -0700 Subject: [PATCH] Fix script to handle property type changes for >2 versions Previously this was comparing both subsequent versions with the latest version, which means if the change conflicts with both earlier versions then we got a table row for each CodeMeta version processed for the tables. Since v2 will not immediately become unsupported due to the amount of adoption, this is necessary for now. At some point the future there may be an end of life process that requires the definitions relocate to elsewhere but there is no consensus yet. --- scripts/properties_to_json.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/properties_to_json.py b/scripts/properties_to_json.py index 90146cc..2afbbf6 100644 --- a/scripts/properties_to_json.py +++ b/scripts/properties_to_json.py @@ -95,15 +95,25 @@ def canonicalize(s): version not in existing_item["versions"] ), f"CodeMeta {version} has duplicated property {item}" existing_item["versions"].append(version) - # check for existing properties that have differing types or descriptions - # values from newer versions of properties_description.json take precedence - # over new ones. + # check for existing properties that have slightly differing types or + # descriptions values from newer versions of properties_description.json + # take precedence over new ones. # update the versions for these here and break to avoid duplicate rows + # Differences that are meaningful are still broken out into their own row if item["Property"] == existing_item["Property"] and item["Parent Type"] == existing_item["Parent Type"]: if canonicalize(item["Type"]) != canonicalize(existing_item["Type"]): - # both types meaningfully differ - item["versions"] = [version] - json_items.append(item) + # If we're going to persist with 2+ supported versions then this + # whole thing probably needs a rewrite. + # But, this dirty fix will work for v4. + p_matches = [p for p in json_items if p["Property"] == item["Property"]] + if len(p_matches) > 1: + indices = [i for i, prop in enumerate(json_items) if prop["Property"] == item["Property"] and (canonicalize(prop["Type"]) == canonicalize(item["Type"]))] + if len(indices) == 1 and version not in json_items[indices[0]]["versions"]: + json_items[indices[0]]["versions"].append(version) + else: + # both types meaningfully differ and this is the only property match + item["versions"] = [version] + json_items.append(item) else: item["Type"] = existing_item["Type"] if version not in existing_item["versions"]: