本文整理汇总了Python中prov.model.ProvBundle.set_default_namespace方法的典型用法代码示例。如果您正苦于以下问题:Python ProvBundle.set_default_namespace方法的具体用法?Python ProvBundle.set_default_namespace怎么用?Python ProvBundle.set_default_namespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prov.model.ProvBundle
的用法示例。
在下文中一共展示了ProvBundle.set_default_namespace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: example_graph
# 需要导入模块: from prov.model import ProvBundle [as 别名]
# 或者: from prov.model.ProvBundle import set_default_namespace [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