Skip to content

Commit

Permalink
Add a working patch option for get_json (#440)
Browse files Browse the repository at this point in the history
* add patch option

* fix stupid mistake
  • Loading branch information
InnocentBug authored Mar 12, 2024
1 parent 6b1738e commit 3cf3c4e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cript/nodes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def get_json(
@dataclass(frozen=True)
class ReturnTuple:
json: str
json_dict: dict
handled_ids: set

# Do not check for circular references, since we handle them manually
Expand All @@ -460,7 +461,12 @@ class ReturnTuple:
NodeEncoder.condense_to_uuid = condense_to_uuid

try:
return ReturnTuple(json.dumps(self, cls=NodeEncoder, **kwargs), NodeEncoder.handled_ids)
tmp_json = json.dumps(self, cls=NodeEncoder, **kwargs)
tmp_dict = json.loads(tmp_json)
if is_patch:
del tmp_dict["uuid"] # patches do not allow UUID is the parent most node

return ReturnTuple(json.dumps(tmp_dict), tmp_dict, NodeEncoder.handled_ids)
except Exception as exc:
# TODO this handling that doesn't tell the user what happened and how they can fix it
# this just tells the user that something is wrong
Expand Down

0 comments on commit 3cf3c4e

Please sign in to comment.