本文整理汇总了Python中prov.model.ProvBundle.wasAttributedTo方法的典型用法代码示例。如果您正苦于以下问题:Python ProvBundle.wasAttributedTo方法的具体用法?Python ProvBundle.wasAttributedTo怎么用?Python ProvBundle.wasAttributedTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prov.model.ProvBundle
的用法示例。
在下文中一共展示了ProvBundle.wasAttributedTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_bundle_mop_sign_form
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def create_bundle_mop_sign_form(user_id,
session_key,
blank_form_serial,
signed_form_id,
form_data=None):
bundle_id = 'b:%s/form/signing/%d' % (session_key, signed_form_id)
b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())
ag = b.agent('mopuser:%d/%s' % (user_id, session_key))
bf = b.entity('form:blank/%s' % blank_form_serial,
[('prov:type', 'asset:BlankForm')])
now = datetime.datetime.now()
a = b.activity('ns:sign-form/%s' % blank_form_serial, now, now)
b.wasAssociatedWith(a, ag)
b.used(a, bf)
data = {'prov:type': 'asset:SignedForm'}
# Add relevant extra data of the form here
if form_data is not None:
data['mop:data'] = form_data
sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id),
data)
b.wasGeneratedBy(sf, a)
b.wasAttributedTo(sf, ag)
return bundle_id, b
示例2: bundles2
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def bundles2():
# https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles2.provn
# ===========================================================================
# document
g = ProvBundle()
# prefix ex <http://example.org/example/>
g.add_namespace("ex", "http://www.example.com/")
# prefix alice <http://example.org/alice/>
# prefix bob <http://example.org/bob/>
g.add_namespace("alice", "http://example.org/alice/")
g.add_namespace("bob", "http://example.org/bob/")
# entity(bob:bundle4, [prov:type='prov:Bundle'])
# wasGeneratedBy(bob:bundle4, -, 2012-05-24T10:30:00)
# agent(ex:Bob)
# wasAttributedTo(bob:bundle4, ex:Bob)
g.entity("bob:bundle4", {"prov:type": PROV["Bundle"]})
g.wasGeneratedBy("bob:bundle4", time="2012-05-24T10:30:00")
g.agent("ex:Bob")
g.wasAttributedTo("bob:bundle4", "ex:Bob")
# entity(alice:bundle5, [ prov:type='prov:Bundle' ])
# wasGeneratedBy(alice:bundle5, -, 2012-05-25T11:15:00)
# agent(ex:Alice)
# wasAttributedTo(alice:bundle5, ex:Alice)
g.entity("alice:bundle5", {"prov:type": PROV["Bundle"]})
g.wasGeneratedBy("alice:bundle5", time="2012-05-25T11:15:00")
g.agent("ex:Alice")
g.wasAttributedTo("alice:bundle5", "ex:Alice")
# bundle bob:bundle4
# entity(ex:report1, [ prov:type="report", ex:version=1 ])
# wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01)
# endBundle
b4 = g.bundle("bob:bundle4")
b4.entity("ex:report1", {"prov:type": "report", "ex:version": 1})
b4.wasGeneratedBy("ex:report1", time="2012-05-24T10:00:01")
# bundle alice:bundle5
# entity(ex:report1bis)
# mentionOf(ex:report1bis, ex:report1, bob:bundle4)
# entity(ex:report2, [ prov:type="report", ex:version=2 ])
# wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01)
# wasDerivedFrom(ex:report2, ex:report1bis)
# endBundle
b5 = g.bundle("alice:bundle5")
b5.entity("ex:report1bis")
b5.mentionOf("ex:report1bis", "ex:report1", "bob:bundle4")
b5.entity("ex:report2", [("prov:type", "report"), ("ex:version", 2)])
b5.wasGeneratedBy("ex:report2", time="2012-05-25T11:00:01")
b5.wasDerivedFrom("ex:report2", "ex:report1bis")
# endDocument
return g
示例3: bundles1
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def bundles1():
# https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles1.provn
# ===============================================================================
# document
g = ProvBundle()
# prefix ex <http://example.org/example/>
EX = Namespace("ex", "http://www.example.com/")
g.add_namespace(EX)
# prefix alice <http://example.org/alice/>
# prefix bob <http://example.org/bob/>
g.add_namespace("alice", "http://example.org/alice/")
g.add_namespace("bob", "http://example.org/bob/")
# entity(bob:bundle1, [prov:type='prov:Bundle'])
g.entity("bob:bundle1", {"prov:type": PROV["Bundle"]})
# wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00)
g.wasGeneratedBy("bob:bundle1", time="2012-05-24T10:30:00")
# agent(ex:Bob)
g.agent("ex:Bob")
# wasAttributedTo(bob:bundle1, ex:Bob)
g.wasAttributedTo("bob:bundle1", "ex:Bob")
# entity(alice:bundle2, [ prov:type='prov:Bundle' ])
g.entity("alice:bundle2", {"prov:type": PROV["Bundle"]})
# wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00)
g.wasGeneratedBy("alice:bundle2", time="2012-05-25T11:15:00")
# agent(ex:Alice)
g.agent("ex:Alice")
# wasAttributedTo(alice:bundle2, ex:Alice)
g.wasAttributedTo("alice:bundle2", "ex:Alice")
# bundle bob:bundle1
b1 = g.bundle("bob:bundle1")
# entity(ex:report1, [ prov:type="report", ex:version=1 ])
b1.entity("ex:report1", {"prov:type": "report", "ex:version": 1})
# wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01)
b1.wasGeneratedBy("ex:report1", time="2012-05-24T10:00:01")
# endBundle
# bundle alice:bundle2
b2 = g.bundle("alice:bundle2")
# entity(ex:report1)
b2.entity("ex:report1")
# entity(ex:report2, [ prov:type="report", ex:version=2 ])
b2.entity("ex:report2", {"prov:type": "report", "ex:version": 2})
# wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01)
b2.wasGeneratedBy("ex:report2", time="2012-05-25T11:00:01")
# wasDerivedFrom(ex:report2, ex:report1)
b2.wasDerivedFrom("ex:report2", "ex:report1")
# endBundle
# endDocument
return g
示例4: createTripCreationGraph
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def createTripCreationGraph(self, userName, userEmail, tripId, tripLegIds, startTime, endTime):
"""Creates and stores the provenacne graph depecting the action of creating the trip"""
#startTime = datetime.datetime.strptime(startTime, "%a, %d %b %Y %H:%M:%S %Z")
#endTime = datetime.datetime.strptime(endTime, "%a, %d %b %Y %H:%M:%S %Z")
#the namespace of the project
cf = Namespace('cf', 'http://users.ecs.soton.ac.uk/pp6g11/ontology/carbonFooprints/')
# create a provenance _container
g = ProvBundle()
g.add_namespace("foaf", "http://xmlns.com/foaf/0.1/")
#create activity
g.activity(cf['tripCreation'], startTime, endTime)
#create entities.
g.entity(cf['trip-' + tripId])
#create trip leg entities
for tripLegId in tripLegIds:
tripLegId = str(tripLegId)
g.entity(cf['tripLeg-' + tripLegId])
g.wasGeneratedBy('cf:tripLeg-' + tripLegId, 'cf:tripCreation')
g.wasDerivedFrom('cf:trip-' + tripId, 'cf:tripLeg-' + tripLegId)
#add relations
g.wasGeneratedBy('cf:trip-' + tripId, 'cf:tripCreation')
#create agent
g.agent('cf:' + userName, {'prov:type': 'prov:Person', 'foaf:mbox': '<mailto:' + userEmail + '>'})
g.wasAssociatedWith('cf:tripCreation', 'cf:' + userName)
g.wasAttributedTo('cf:trip-' + tripId, 'cf:' + userName)
#save the graph
pdBundle = save_bundle(g)
#visualize the graph
path = tempfile.mkdtemp()
filepath = os.path.join(path, 'dot-test.png')
# Convert it to DOT
dot = graph.prov_to_dot(g)
dot.set_dpi(120)
# Write it to a temporary PNG file
#dot.write_png(filepath)
# Display it using matplotlib
#img = mpimg.imread(filepath)
##imgplot = plt.imshow(img)
#plt.show()
#os.remove(filepath)
return pdBundle
示例5: create_bundle_mop_send_form
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def create_bundle_mop_send_form(user_id, session_key, signed_form_id, blank_form_serial, email_id, unit_serial):
bundle_id = 'b:%s/form/sending/%d' % (session_key, email_id)
b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())
ag = b.agent('mopuser:%d/%s' % (user_id, session_key))
em = b.entity('email:%d' % email_id, [('prov:type', 'mop:Email'), ('mop:mailto', unit_serial)])
sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id), [('prov:type', 'asset:SignedForm')]) # Add relevant extra data of the form here
now = datetime.datetime.now()
b.wasDerivedFrom(em, sf, time=now)
b.wasAttributedTo(em, ag)
return bundle_id, b
示例6: bundles1
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def bundles1():
# https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/bundles1.provn
#===============================================================================
# bundle
#
# prefix ex <http://example.org/example/>
#
# prefix alice <http://example.org/alice/>
# prefix bob <http://example.org/bob/>
#
# entity(bob:bundle1, [prov:type='prov:Bundle'])
# wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00)
# agent(ex:Bob)
# wasAttributedTo(bob:bundle1, ex:Bob)
#
# entity(alice:bundle2, [ prov:type='prov:Bundle' ])
# wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00)
# agent(ex:Alice)
# wasAttributedTo(alice:bundle2, ex:Alice)
#
# bundle bob:bundle1
# entity(ex:report1, [ prov:type="report", ex:version=1 ])
# wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01)
# endBundle
#
# bundle alice:bundle2
# entity(ex:report1)
# entity(ex:report2, [ prov:type="report", ex:version=2 ])
# wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01)
# wasDerivedFrom(ex:report2, ex:report1)
# endBundle
#
# endBundle
#===============================================================================
EX = Namespace("ex","http://www.example.com/")
g = ProvBundle()
g.add_namespace(EX)
g.add_namespace('alice', 'http://example.org/alice/')
g.add_namespace('bob', 'http://example.org/bob/')
g.entity('bob:bundle1', {'prov:type': PROV['Bundle']})
g.wasGeneratedBy('bob:bundle1', time='2012-05-24T10:30:00')
g.agent('ex:Bob')
g.wasAttributedTo('bob:bundle1', 'ex:Bob')
g.entity('alice:bundle2', {'prov:type': PROV['Bundle']})
g.wasGeneratedBy('alice:bundle2', time='2012-05-25T11:15:00')
g.agent('ex:Alice')
g.wasAttributedTo('alice:bundle2', 'ex:Alice')
b1 = g.bundle('bob:bundle1')
b1.entity('ex:report1', {'prov:type': "report", 'ex:version': 1})
b1.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01')
b2 = g.bundle('alice:bundle2')
b2.entity('ex:report1')
b2.entity('ex:report2', {'prov:type': "report", 'ex:version': 2})
b2.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01')
b2.wasDerivedFrom('ex:report2', 'ex:report1')
return g
示例7: primer_example
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def primer_example():
# https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/primer.pn
#===========================================================================
# bundle
#
# prefix ex <http://example/>
#
# entity(ex:article, [dcterms:title="Crime rises in cities"])
# entity(ex:dataSet1)
# entity(ex:dataSet2)
# entity(ex:regionList)
# entity(ex:composition)
# entity(ex:chart1)
# entity(ex:chart2)
#
#
# activity(ex:compile)
# activity(ex:compose)
# activity(ex:illustrate)
#
#
# used(ex:compose, ex:dataSet1, -)
# used(ex:compose, ex:regionList, -)
# wasGeneratedBy(ex:composition, ex:compose, -)
#
# used(ex:illustrate, ex:composition, -)
# wasGeneratedBy(ex:chart1, ex:illustrate, -)
#
#
# agent(ex:derek, [ prov:type="prov:Person", foaf:givenName = "Derek",
# foaf:mbox= "<mailto:[email protected]>"])
# wasAssociatedWith(ex:compose, ex:derek, -)
# wasAssociatedWith(ex:illustrate, ex:derek, -)
#
# agent(ex:chartgen, [ prov:type="prov:Organization",
# foaf:name = "Chart Generators Inc"])
# actedOnBehalfOf(ex:derek, ex:chartgen, ex:compose)
#
# wasAttributedTo(ex:chart1, ex:derek)
#
#
# used(ex:compose, ex:dataSet1, -, [ prov:role = "ex:dataToCompose"])
# used(ex:compose, ex:regionList, -, [ prov:role = "ex:regionsToAggregteBy"])
#
#
# wasRevisionOf(ex:dataSet2, ex:dataSet1, -)
# wasDerivedFrom(ex:chart2, ex:dataSet2)
#
# endBundle
#===========================================================================
ex = Namespace('ex', 'http://example/')
g = ProvBundle()
g.add_namespace("dcterms","http://purl.org/dc/terms/")
g.entity(ex['article'], {'dcterms:title': "Crime rises in cities"})
g.entity(ex['dataSet1'])
g.entity(ex['dataSet2'])
g.entity(ex['regionList'])
g.entity(ex['composition'])
g.entity(ex['chart1'])
g.entity(ex['chart2'])
g.activity(ex['compile'])
g.activity(ex['compose'])
g.activity(ex['illustrate'])
g.used('ex:compose', 'ex:dataSet1', other_attributes={'prov:role' : "ex:dataToCompose"})
g.used('ex:compose', 'ex:regionList', other_attributes={'prov:role' : "ex:regionsToAggregateBy"})
g.wasGeneratedBy('ex:composition', 'ex:compose')
g.used('ex:illustrate', 'ex:composition')
g.wasGeneratedBy('ex:chart1', 'ex:illustrate')
g.agent('ex:derek', {'prov:type': "prov:Person", 'foaf:givenName': "Derek", 'foaf:mbox': "<mailto:[email protected]>"})
g.wasAssociatedWith('ex:compose', 'ex:derek')
g.wasAssociatedWith('ex:illustrate', 'ex:derek')
g.agent('ex:chartgen', {'prov:type': "prov:Organization", 'foaf:name' : "Chart Generators Inc"})
g.actedOnBehalfOf('ex:derek', 'ex:chartgen', 'ex:compose')
g.wasAttributedTo('ex:chart1', 'ex:derek')
g.wasRevisionOf('ex:dataSet2', 'ex:dataSet1')
g.wasDerivedFrom('ex:chart2', 'ex:dataSet2')
return g
示例8: primer_example
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
def primer_example():
# https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/primer.pn
# ===========================================================================
# document
g = ProvBundle()
# prefix ex <http://example/>
# prefix dcterms <http://purl.org/dc/terms/>
# prefix foaf <http://xmlns.com/foaf/0.1/>
ex = Namespace("ex", "http://example/") # namespaces do not need to be explicitly added to a document
g.add_namespace("dcterms", "http://purl.org/dc/terms/")
g.add_namespace("foaf", "http://xmlns.com/foaf/0.1/")
# entity(ex:article, [dcterms:title="Crime rises in cities"])
g.entity(
ex["article"], {"dcterms:title": "Crime rises in cities"}
) # first time the ex namespace was used, it is added to the document automatically
# entity(ex:articleV1)
g.entity(ex["articleV1"])
# entity(ex:articleV2)
g.entity(ex["articleV2"])
# entity(ex:dataSet1)
g.entity(ex["dataSet1"])
# entity(ex:dataSet2)
g.entity(ex["dataSet2"])
# entity(ex:regionList)
g.entity(ex["regionList"])
# entity(ex:composition)
g.entity(ex["composition"])
# entity(ex:chart1)
g.entity(ex["chart1"])
# entity(ex:chart2)
g.entity(ex["chart2"])
# entity(ex:blogEntry)
g.entity(ex["blogEntry"])
# activity(ex:compile)
g.activity("ex:compile") # since ex is registered, it can be used like this
# activity(ex:compile2)
g.activity("ex:compile2")
# activity(ex:compose)
g.activity("ex:compose")
# activity(ex:correct, 2012-03-31T09:21:00, 2012-04-01T15:21:00)
g.activity("ex:correct", "2012-03-31T09:21:00", "2012-04-01T15:21:00") # date time can be provided as strings
# activity(ex:illustrate)
g.activity("ex:illustrate")
# used(ex:compose, ex:dataSet1, -, [ prov:role = "ex:dataToCompose"])
g.used("ex:compose", "ex:dataSet1", other_attributes={"prov:role": "ex:dataToCompose"})
# used(ex:compose, ex:regionList, -, [ prov:role = "ex:regionsToAggregateBy"])
g.used("ex:compose", "ex:regionList", other_attributes={"prov:role": "ex:regionsToAggregateBy"})
# wasGeneratedBy(ex:composition, ex:compose, -)
g.wasGeneratedBy("ex:composition", "ex:compose")
# used(ex:illustrate, ex:composition, -)
g.used("ex:illustrate", "ex:composition")
# wasGeneratedBy(ex:chart1, ex:illustrate, -)
g.wasGeneratedBy("ex:chart1", "ex:illustrate")
# wasGeneratedBy(ex:chart1, ex:compile, 2012-03-02T10:30:00)
g.wasGeneratedBy("ex:chart1", "ex:compile", "2012-03-02T10:30:00")
# wasGeneratedBy(ex:chart2, ex:compile2, 2012-04-01T15:21:00)
#
#
# agent(ex:derek, [ prov:type="prov:Person", foaf:givenName = "Derek",
# foaf:mbox= "<mailto:[email protected]>"])
g.agent(
"ex:derek", {"prov:type": PROV["Person"], "foaf:givenName": "Derek", "foaf:mbox": "<mailto:[email protected]>"}
)
# wasAssociatedWith(ex:compose, ex:derek, -)
g.wasAssociatedWith("ex:compose", "ex:derek")
# wasAssociatedWith(ex:illustrate, ex:derek, -)
g.wasAssociatedWith("ex:illustrate", "ex:derek")
#
# agent(ex:chartgen, [ prov:type="prov:Organization",
# foaf:name = "Chart Generators Inc"])
g.agent("ex:chartgen", {"prov:type": PROV["Organization"], "foaf:name": "Chart Generators Inc"})
# actedOnBehalfOf(ex:derek, ex:chartgen, ex:compose)
g.actedOnBehalfOf("ex:derek", "ex:chartgen", "ex:compose")
# wasAttributedTo(ex:chart1, ex:derek)
g.wasAttributedTo("ex:chart1", "ex:derek")
# wasGeneratedBy(ex:dataSet2, ex:correct, -)
g.wasGeneratedBy("ex:dataSet2", "ex:correct")
# used(ex:correct, ex:dataSet1, -)
g.used("ex:correct", "ex:dataSet1")
# wasDerivedFrom(ex:dataSet2, ex:dataSet1, [prov:type='prov:Revision'])
g.wasDerivedFrom("ex:dataSet2", "ex:dataSet1", other_attributes={"prov:type": PROV["Revision"]})
# wasDerivedFrom(ex:chart2, ex:dataSet2)
g.wasDerivedFrom("ex:chart2", "ex:dataSet2")
# wasDerivedFrom(ex:blogEntry, ex:article, [prov:type='prov:Quotation'])
g.wasDerivedFrom("ex:blogEntry", "ex:article", other_attributes={"prov:type": PROV["Quotation"]})
# specializationOf(ex:articleV1, ex:article)
g.specializationOf("ex:articleV1", "ex:article")
# wasDerivedFrom(ex:articleV1, ex:dataSet1)
g.wasDerivedFrom("ex:articleV1", "ex:dataSet1")
# specializationOf(ex:articleV2, ex:article)
g.specializationOf("ex:articleV2", "ex:article")
#.........这里部分代码省略.........
示例9: open
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import wasAttributedTo [as 别名]
g.entity(ex['dataSet2'])
g.entity(ex['regionList'])
g.entity(ex['composition'])
g.entity(ex['chart1'])
g.entity(ex['chart2'])
g.activity(ex['compile'])
g.activity(ex['compose'])
g.activity(ex['illustrate'])
g.used('ex:compose', 'ex:dataSet1', other_attributes={'prov:role' : "ex:dataToCompose"})
g.used('ex:compose', 'ex:regionList', other_attributes={'prov:role' : "ex:regionsToAggregateBy"})
g.wasGeneratedBy('ex:composition', 'ex:compose')
g.used('ex:illustrate', 'ex:composition')
g.wasGeneratedBy('ex:chart1', 'ex:illustrate')
g.agent('ex:derek', {'prov:type': "prov:Person", 'foaf:givenName': "Derek", 'foaf:mbox': "<mailto:[email protected]>"})
g.wasAssociatedWith('ex:compose', 'ex:derek')
g.wasAssociatedWith('ex:illustrate', 'ex:derek')
g.agent('ex:chartgen', {'prov:type': "prov:Organization", 'foaf:name' : "Chart Generators Inc"})
g.actedOnBehalfOf('ex:derek', 'ex:chartgen', 'ex:compose')
g.wasAttributedTo('ex:chart1', 'ex:derek')
g.wasRevisionOf('ex:dataSet2', 'ex:dataSet1')
g.wasDerivedFrom('ex:chart2', 'ex:dataSet2')
with open('/Users/jason/Documents/ProvenanceTools/JasonTest3.provn', 'wt') as fp:
fp.writelines(g.get_provn())