Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/shacl2code/lang/templates/python.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,19 @@ class SHACLObjectSet(object):
self.add_index(obj)
return obj

def remove(self, obj: SHACLObject) -> None:
"""
Remove object from object set

Remove a SHACLObject from the object set and rebuild index.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is fine. Just keep in mind the object might still be in the graph if it's referenced indirectly by another object

Rebuilding the whole index is probably the safest for now; I don't expect this to be a very common operation

"""
if not isinstance(obj, SHACLObject):
raise TypeError("Object is not of type SHACLObject")

if obj in self.objects:
self.objects.remove(obj)
self.create_index()

def update(self, *others) -> None:
"""
Update object set adding all objects in each other iterable
Expand Down
Loading