File: parse_patch.py

package info (click to toggle)
rdflib 7.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 77,852 kB
  • sloc: python: 59,555; sh: 153; makefile: 83; ruby: 74; xml: 45
file content (35 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()