def test_set_was_generated_by(self): entity = prov.Entity("test:entity") entity.set_label("example entity") activity = prov.Activity("test:activity") activity.set_label("example activity") entity.set_was_generated_by(activity) ttl = prov.serialize(format="turtle") self.assertIsNotNone(ttl)
# Time dt1 = datetime.strptime("2012-03-02T10:30:00", "%Y-%m-%dT%H:%M:%S") chart1.set_generated_at_time(dt1) dt2 = datetime.strptime("2012-04-01T15:21:00", "%Y-%m-%dT%H:%M:%S") chart2.set_generated_at_time(dt2) dt3 = datetime.strptime("2012-03-31T09:21:00", "%Y-%m-%dT%H:%M:%S") correct1.set_started_at_time(dt3) dt4 = datetime.strptime("2012-04-01T15:21:00", "%Y-%m-%dT%H:%M:%S") correct1.set_ended_at_time(dt4) # Alternate entities and specialization quoteInBlogEntry = prov.Entity("ex:quoteInBlogEntry-20130326") quoteInBlogEntry.set_was_quoted_from(article) article_v1 = prov.Entity("ex:article_v1") article_v1.set_specialization_of(article) article_v2 = prov.Entity("ex:article_v2") article_v2.set_specialization_of(article) article_v2.set_alternate_of(article_v1) # print RDF serialization as turtle print(prov.serialize(format="turtle"))
__author__ = 'szednik' from kleio import prov # load the existing PROV-O graph prov.default_graph.load("load-example.json", format="json-ld") # get a reference to the existing entity with id="test:entity" entity = prov.Entity("test:entity") # define a new entity and say it was derived from "test:entity" derived_entity = prov.Entity("test:derived_entity") derived_entity.set_label("derived example entity") derived_entity.set_was_derived_from(entity) # note, right now the context of the import is not retained # add test and foaf namespace to prov.context for serialization prov.context.update({ "test": "http://tw.rpi.edu/ns/test#", "foaf": "http://xmlns.com/foaf/0.1/" }) # print out the updated provenance graph print(prov.serialize(format="json-ld"))
def test_serialize_ntriples(self): entity = prov.Entity("test:entity") entity.set_label("example entity") ntriples = prov.serialize(format="nt") self.assertIsNotNone(ntriples)
def test_serialize_n3(self): entity = prov.Entity("test:entity") entity.set_label("example entity") n3 = prov.serialize(format="n3") self.assertIsNotNone(n3)
def test_serialize_jsonld(self): entity = prov.Entity("test:entity") entity.set_label("example entity") jsonld = prov.serialize(format="json-ld") self.assertIsNotNone(jsonld)
def test_serialize_rdfxml(self): entity = prov.Entity("test:entity") entity.set_label("example entity") rdfxml = prov.serialize(format="xml") self.assertIsNotNone(rdfxml)
def test_serialize_trig(self): entity = prov.Entity("test:entity") entity.set_label("example entity") trig = prov.serialize(format="trig") self.assertIsNotNone(trig)
def test_serialize_turtle(self): entity = prov.Entity("test:entity") entity.set_label("example entity") ttl = prov.serialize(format="turtle") self.assertIsNotNone(ttl)
def test_serialize_default(self): entity = prov.Entity("test:entity") entity.set_label("example entity") out = prov.serialize() self.assertIsNotNone(out)
__author__ = 'szednik' from kleio import prov # load the existing PROV-O graph prov.default_graph.load("load-example.json", format="json-ld") # get a reference to the existing entity with id="test:entity" entity = prov.Entity("test:entity") # define a new entity and say it was derived from "test:entity" derived_entity = prov.Entity("test:derived_entity") derived_entity.set_label("derived example entity") derived_entity.set_was_derived_from(entity) # note, right now the context of the import is not retained # add test and foaf namespace to prov.context for serialization prov.context.update({"test": "http://tw.rpi.edu/ns/test#", "foaf": "http://xmlns.com/foaf/0.1/"}) # print out the updated provenance graph print(prov.serialize(format="json-ld"))
__author__ = 'szednik' from kleio import prov prov.ns("test", "http://test.com/ns#") my_bundle = prov.bundle(id="test:bundle") bundle_entity = prov.bundle_entity(bundle=my_bundle) bundle_entity.set_label("bundle entity") entity = prov.Entity(id="test:entity-in-bundle", bundle=my_bundle) entity.set_label("entity in bundle") entity_not_in_bundle = prov.Entity(id="test:entity-not-in-bundle") entity_not_in_bundle.set_label("entity not in bundle") # Serialize using TriG to see the bundle container as a named graph # and PROV assertions not associated with a bundle in the default graph print(prov.serialize(format="trig")) # Serialize using the bundle parameter to see only PROV # assertions associated with the specified bundle print(prov.serialize(format="trig", bundle=my_bundle))
__author__ = 'szednik' from kleio import prov # load the existing PROV-O graph prov.default_graph.load("load-example.ttl", format="turtle") # get a reference to the existing entity with id="test:entity" entity = prov.Entity("test:entity") # define a new entity and say it was derived from "test:entity" derived_entity = prov.Entity("test:derived_entity") derived_entity.set_label("derived example entity") derived_entity.set_was_derived_from(entity) # print out the updated provenance graph print(prov.serialize())