Skip to content

Commit

Permalink
fix: [uuid] quote confusion fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
adulau committed Mar 4, 2025
1 parent 6f296cc commit 2425ce4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gen_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
filepath = os.path.join(root, filename)
with open(filepath, 'r') as file:
content = json.load(file)

# Create namespace UUID
ns_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, content["namespace"])
content["uuid"] = str(ns_uuid)

# Create predicate UUID
pred_uuid_map = {}
for i, predicate in enumerate(content["predicates"]):
name = f"{content["namespace"]}:{content["predicates"][i]["value"]}"
name = f"{content['namespace']}:{content['predicates'][i]['value']}"
predicate_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, name)
content["predicates"][i]["uuid"] = str(predicate_uuid)
pred_uuid_map[content["predicates"][i]["value"]] = predicate_uuid
Expand All @@ -28,14 +28,14 @@
try:
for i, value in enumerate(content["values"]):
for j, entry in enumerate(content["values"][i]["entry"]):
name = f"{content["namespace"]}:{content["values"][i]["predicate"]}=\"{content["values"][i]["entry"][j]["value"]}\""
name = f"{content['namespace']}:{content['values'][i]['predicate']}=\"{content['values'][i]['entry'][j]['value']}\""
puuid = pred_uuid_map[content["values"][i]["predicate"]]
content["values"][i]["entry"][j]["uuid"] = str(uuid.uuid5(uuid.NAMESPACE_DNS, name))
content["values"][i]["entry"][j]["uuid"] = str(
uuid.uuid5(uuid.NAMESPACE_DNS, name)
)
except Exception as e:
print(f"Exception: {e}")
pass

with open(filepath, 'w') as file:
json.dump(content, file, indent=4)


0 comments on commit 2425ce4

Please sign in to comment.