diff options
author | Nicholas Car <nicholas.car@surroundaustralia.com> | 2021-04-25 21:20:53 +1000 |
---|---|---|
committer | Nicholas Car <nicholas.car@surroundaustralia.com> | 2021-04-25 21:20:53 +1000 |
commit | bb03d810ffd0504c86476f3fd5f9ee31026376f9 (patch) | |
tree | e4661d03e1bbdb5188ad74a04bd994b22f9f66f8 /examples/simple_example.py | |
parent | f447b0f23fba59df15bc6b31735bdb18d2940bd4 (diff) | |
download | rdflib-bb03d810ffd0504c86476f3fd5f9ee31026376f9.tar.gz |
removed simple_example as it didn't do anything interesting
Diffstat (limited to 'examples/simple_example.py')
-rw-r--r-- | examples/simple_example.py | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/examples/simple_example.py b/examples/simple_example.py deleted file mode 100644 index 15ae0d81..00000000 --- a/examples/simple_example.py +++ /dev/null @@ -1,59 +0,0 @@ -from rdflib import Graph, Literal, BNode, RDF -from rdflib.namespace import FOAF, DC - -if __name__ == "__main__": - - store = Graph() - - # Bind a few prefix, namespace pairs for pretty output - store.bind("dc", DC) - store.bind("foaf", FOAF) - - # Create an identifier to use as the subject for Donna. - donna = BNode() - - # Add triples using store's add method. - store.add((donna, RDF.type, FOAF.Person)) - store.add((donna, FOAF.nick, Literal("donna", lang="foo"))) - store.add((donna, FOAF.name, Literal("Donna Fales"))) - - # Iterate over triples in store and print them out. - print("--- printing raw triples ---") - for s, p, o in store: - print(s, p, o) - - # For each foaf:Person in the store print out its mbox property. - print() - print("--- printing mboxes ---") - for person in store.subjects(RDF.type, FOAF["Person"]): - for mbox in store.objects(person, FOAF["mbox"]): - print(mbox) - - print("--- saving RDF to a file (donna_foaf.rdf) ---") - # Serialize the store as RDF/XML to the file donna_foaf.rdf. - store.serialize("donna_foaf.rdf", format="pretty-xml", max_depth=3) - - # Let's show off the serializers - print() - print("RDF Serializations:") - - # Serialize as XML - print("--- start: rdf-xml ---") - print(store.serialize(format="pretty-xml").decode("utf-8")) - print("--- end: rdf-xml ---\n") - - # Serialize as Turtle - print("--- start: turtle ---") - print(store.serialize(format="turtle").decode("utf-8")) - print("--- end: turtle ---\n") - - # Serialize as NTriples - print("--- start: ntriples ---") - print(store.serialize(format="nt").decode("utf-8")) - print("--- end: ntriples ---\n") - - # Serialize as JSON-LD - # only if you have the JSON-LD plugin installed! - print("--- start: JSON-LD ---") - print(store.serialize(format="json-ld").decode("utf-8")) - print("--- end: JSON-LD ---\n") |