Skip to content

Commit 0eb4764

Browse files
meldraprogval
authored andcommitted
Refactor the merging logic to work
1 parent c58d1ca commit 0eb4764

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

scripts/properties_to_json.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,26 @@
8585
# Look for a similar existing item from a newer CodeMeta version
8686
for existing_item in json_items:
8787
if existing_item.items() >= item.items():
88-
# We found an existing item, add this version to its list
88+
# We found an identical existing item, add this version to its list
8989
assert (
9090
version not in existing_item["versions"]
9191
), f"CodeMeta {version} has duplicated property {item}"
9292
existing_item["versions"].append(version)
93-
94-
# values from newer versions of properties_description.json take precedence
95-
# over new ones
96-
if item["Type"]:
97-
existing_item["Type"] = item["Type"]
98-
if item["Description"]:
99-
existing_item["Description"] = item["Description"]
93+
# check for existing properties that have differing types or descriptions
94+
# values from newer versions of properties_description.json take precedence
95+
# over new ones.
96+
# update the versions for these here and break to avoid duplicate rows
97+
if item["Property"] == existing_item["Property"]:
98+
if item["Type"] != existing_item["Type"]:
99+
item["Type"] = existing_item["Type"]
100+
if version not in existing_item["versions"]:
101+
existing_item["versions"].append(version)
102+
if item["Description"] != existing_item["Description"]:
103+
item["Description"] = existing_item["Description"]
104+
if version not in existing_item["versions"]:
105+
existing_item["versions"].append(version)
100106
break
107+
101108
else:
102109
# No similar item, create a new one
103110
item["versions"] = [version]

0 commit comments

Comments
 (0)