本文整理汇总了Python中prov.model.ProvBundle.entity方法的典型用法代码示例。如果您正苦于以下问题:Python ProvBundle.entity方法的具体用法?Python ProvBundle.entity怎么用?Python ProvBundle.entity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prov.model.ProvBundle
的用法示例。
在下文中一共展示了ProvBundle.entity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_bundle_mop_sign_form
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [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 entity [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: long_literals
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def long_literals():
g = ProvBundle()
long_uri = "http://Lorem.ipsum/dolor/sit/amet/consectetur/adipiscing/elit/Quisque/vel/sollicitudin/felis/nec/venenatis/massa/Aenean/lectus/arcu/sagittis/sit/amet/nisl/nec/varius/eleifend/sem/In/hac/habitasse/platea/dictumst/Aliquam/eget/fermentum/enim/Curabitur/auctor/elit/non/ipsum/interdum/at/orci/aliquam/"
ex = Namespace('ex', long_uri)
g.add_namespace(ex)
g.entity('ex:e1', {'prov:label': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque luctus nulla vel ullamcorper. Donec sit amet ligula sit amet lorem pretium rhoncus vel vel lorem. Sed at consequat metus, eget eleifend massa. Fusce a facilisis turpis. Lorem volutpat.'})
return g
示例4: bundles1
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [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
示例5: createTripCreationGraph
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [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
示例6: create_bundle_mop_send_form
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [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
示例7: create_bundle_mop_issue_form
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def create_bundle_mop_issue_form(user_id, session_key, signed_form_id, old_blank_form_serial, email_id, new_blank_form_serial, unit_serial):
# t = long(time.time())
bundle_id = 'b:%s/form/issue/%s' % (session_key, new_blank_form_serial)
b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())
ag = b.agent('dept:%s' % unit_serial)
sf = b.entity('form:signed/%s/%d' % (old_blank_form_serial, signed_form_id))
em = b.entity('email:%d' % email_id)
now = datetime.datetime.now()
a = b.activity('bs:issue-form/%s' % new_blank_form_serial, now, now)
b.wasAssociatedWith(a, ag)
b.used(a, em)
nf = b.entity('form:blank/%s' % new_blank_form_serial)
b.wasGeneratedBy(nf, a)
b.wasDerivedFrom(nf, sf)
return bundle_id, b
示例8: example_graph
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def example_graph():
FOAF = Namespace("foaf","http://xmlns.com/foaf/0.1/")
EX = Namespace("ex","http://www.example.com/")
DCTERMS = Namespace("dcterms","http://purl.org/dc/terms/")
# create a provenance _container
g = ProvBundle()
# Set the default _namespace name
g.set_default_namespace(EX.get_uri())
g.add_namespace(DCTERMS)
# add entities, first define the _attributes in a dictionary
e0_attrs = {PROV["type"]: "File",
EX["path"]: "/shared/crime.txt",
EX["creator"]: "Alice"}
# then create the entity
# If you give the id as a string, it will be treated as a localname
# under the default _namespace
e0 = g.entity(EX["e0"], e0_attrs)
# define the _attributes for the next entity
lit0 = Literal("2011-11-16T16:06:00", XSD["dateTime"])
attrdict ={PROV["type"]: EX["File"],
EX["path"]: "/shared/crime.txt",
DCTERMS["creator"]: FOAF['Alice'],
EX["content"]: "",
DCTERMS["create"]: lit0}
# create the entity, note this time we give the id as a PROVQname
e1 = g.entity(FOAF['Foo'], attrdict)
# add activities
# You can give the _attributes during the creation if there are not many
a0 = g.activity(EX['a0'], datetime.datetime(2008, 7, 6, 5, 4, 3), None, {PROV["type"]: EX["create-file"]})
g0 = g.wasGeneratedBy(e0, a0, None, "g0", {EX["fct"]: "create"})
attrdict={EX["fct"]: "load",
EX["typeexample"] : Literal("MyValue", EX["MyType"])}
u0 = g.used(a0, e1, None, "u0", attrdict)
# The id for a relation is an optional argument, The system will generate one
# if you do not specify it
g.wasDerivedFrom(e0, e1, a0, g0, u0)
return g
示例9: collections
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def collections():
g = ProvBundle()
ex = Namespace("ex", "http://example.org/")
c1 = g.collection(ex["c1"])
e1 = g.entity("ex:e1")
g.hadMember(c1, e1)
return g
示例10: collections
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def collections():
g = ProvBundle()
ex = Namespace('ex', 'http://example.org/')
c1 = g.collection(ex['c1'])
e1 = g.entity('ex:e1')
g.hadMember(c1, e1)
return g
示例11: datatypes
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def datatypes():
g = ProvBundle()
ex = Namespace('ex', 'http://example.org/')
g.add_namespace(ex)
attributes = {'ex:int': 100,
'ex:float': 100.123456,
'ex:long': 123456789000,
'ex:bool': True,
'ex:str': 'Some string',
'ex:unicode': u'Some unicode string with accents: Huỳnh Trung Đông',
'ex:timedate': datetime.datetime(2012, 12, 12, 14, 7, 48)}
multiline = """Line1
Line2
Line3"""
attributes['ex:multi-line'] = multiline
g.entity('ex:e1', attributes)
return g
示例12: create_bundle_mop_issue_document
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def create_bundle_mop_issue_document(user_id, session_key, email_id, blank_form_serial, signed_form_id, document_serial, document_instance_id, unit_serial):
bundle_id = 'b:%s/document/issue/%s' % (session_key, document_instance_id)
b = ProvBundle(namespaces=DEFAULT_NAMESPACES)
b.add_namespace('ns', b.valid_identifier(bundle_id + '/').get_uri())
ag = b.agent('dept:%s' % unit_serial)
sf = b.entity('form:signed/%s/%d' % (blank_form_serial, signed_form_id))
em = b.entity('email:%d' % email_id)
now = datetime.datetime.now()
a = b.activity('bs:issue-document/%d' % document_instance_id, now, now)
b.wasAssociatedWith(a, ag)
b.used(a, em)
d = b.entity('document:%s' % document_serial, [('prov:type', 'asset:Document')])
b.used(a, d)
di = b.entity('document:%s/%d' % (document_serial, document_instance_id), [('prov:type', 'asset:MopDocumentInstance')])
b.wasGeneratedBy(di, a)
b.wasDerivedFrom(di, sf)
b.wasDerivedFrom(di, d)
return bundle_id, b
示例13: datatypes
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def datatypes():
g = ProvBundle()
ex = Namespace("ex", "http://example.org/")
g.add_namespace(ex)
attributes = {
"ex:int": 100,
"ex:float": 100.123456,
"ex:long": 123456789000,
"ex:bool": True,
"ex:str": "Some string",
"ex:unicode": u"Some unicode string with accents: Huỳnh Trung Đông",
"ex:timedate": datetime.datetime(2012, 12, 12, 14, 7, 48),
}
multiline = """Line1
Line2
Line3"""
attributes["ex:multi-line"] = multiline
g.entity("ex:e1", attributes)
return g
示例14: w3c_publication_2
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [as 别名]
def w3c_publication_2():
# https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/w3c-publication2.prov-asn
#===========================================================================
# bundle
#
# prefix ex <http://example.org/>
# prefix rec <http://example.org/record>
#
# prefix w3 <http://www.w3.org/TR/2011/>
# prefix hg <http://dvcs.w3.org/hg/prov/raw-file/9628aaff6e20/model/releases/WD-prov-dm-20111215/>
#
#
# entity(hg:Overview.html, [ prov:type="file in hg" ])
# entity(w3:WD-prov-dm-20111215, [ prov:type="html4" ])
#
#
# activity(ex:rcp,-,-,[prov:type="copy directory"])
#
# wasGeneratedBy(rec:g; w3:WD-prov-dm-20111215, ex:rcp, -)
#
# entity(ex:req3, [ prov:type="http://www.w3.org/2005/08/01-transitions.html#pubreq" %% xsd:anyURI ])
#
# used(rec:u; ex:rcp,hg:Overview.html,-)
# used(ex:rcp, ex:req3, -)
#
#
# wasDerivedFrom(w3:WD-prov-dm-20111215, hg:Overview.html, ex:rcp, rec:g, rec:u)
#
# agent(ex:webmaster, [ prov:type='prov:Person' ])
#
# wasAssociatedWith(ex:rcp, ex:webmaster, -)
#
# endBundle
#===========================================================================
ex = Namespace('ex', 'http://example.org/')
rec = Namespace('rec', 'http://example.org/record')
w3 = Namespace('w3', 'http://www.w3.org/TR/2011/')
hg = Namespace('hg', 'http://dvcs.w3.org/hg/prov/raw-file/9628aaff6e20/model/releases/WD-prov-dm-20111215/')
g = ProvBundle()
g.entity(hg['Overview.html'], {'prov:type': "file in hg"})
g.entity(w3['WD-prov-dm-20111215'], {'prov:type': "html4"})
g.activity(ex['rcp'], None, None, {'prov:type': "copy directory"})
g.wasGeneratedBy('w3:WD-prov-dm-20111215', 'ex:rcp', identifier=rec['g'])
g.entity('ex:req3', {'prov:type': Identifier("http://www.w3.org/2005/08/01-transitions.html#pubreq")})
g.used('ex:rcp', 'hg:Overview.html', identifier='rec:u')
g.used('ex:rcp', 'ex:req3')
g.wasDerivedFrom('w3:WD-prov-dm-20111215', 'hg:Overview.html', 'ex:rcp', 'rec:g', 'rec:u')
g.agent('ex:webmaster', {'prov:type': "Person"})
g.wasAssociatedWith('ex:rcp', 'ex:webmaster')
return g
示例15: bundles1
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import entity [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