parse_patch
Functions:
-
main–
main
Source code in examples/parse_patch.py
source: false show_docstring_attributes: false show_docstring_functions: false show_docstring_modules: false show_docstring_classes: false show_signature: false show_signature_annotations: false show_signature_type_parameters: false show_docstring_other_parameters: false show_docstring_parameters: false show_docstring_raises: false show_docstring_receives: false show_docstring_returns: false summary: false show_if_no_docstring: false
from rdflib import Dataset
def main():
# RDF patch data
add_patch = """
TX .
A _:bn1 <http://example.org/predicate1> "object1" .
A _:bn1 <http://example.org/predicate2> "object2" .
TC .
"""
delete_patch = """
TX .
D _:bn1 <http://example.org/predicate1> "object1" .
TC .
"""
ds = Dataset()
# Apply add patch
ds.parse(data=add_patch, format="patch")
print("After add patch:")
for triple in ds:
print(triple)
# Apply delete patch
ds.parse(data=delete_patch, format="patch")
print("After delete patch:")
for triple in ds:
print(triple)
if __name__ == "__main__":
main()