当前位置: 首页>>代码示例>>Python>>正文


Python ProvDocument.set_default_namespace方法代码示例

本文整理汇总了Python中prov.model.ProvDocument.set_default_namespace方法的典型用法代码示例。如果您正苦于以下问题:Python ProvDocument.set_default_namespace方法的具体用法?Python ProvDocument.set_default_namespace怎么用?Python ProvDocument.set_default_namespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prov.model.ProvDocument的用法示例。


在下文中一共展示了ProvDocument.set_default_namespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_default_namespace_inheritance

# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import set_default_namespace [as 别名]
 def test_default_namespace_inheritance(self):
     prov_doc = ProvDocument()
     prov_doc.set_default_namespace('http://www.example.org/')
     bundle = prov_doc.bundle('bundle')
     e1 = bundle.entity('e1')
     self.assertIsNotNone(e1.identifier, "e1's identifier is None!")
     self.assertRoundTripEquivalence(prov_doc)
开发者ID:krischer,项目名称:prov,代码行数:9,代码来源:qnames.py

示例2: test_bundle_update_simple

# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import set_default_namespace [as 别名]
    def test_bundle_update_simple(self):
        doc = ProvDocument()
        doc.set_default_namespace(EX_URI)

        b1 = doc.bundle('b1')
        b1.entity('e')

        b2 = doc.bundle('b2')
        b2.entity('e')

        self.assertRaises(ProvException, lambda: b1.update(1))
        self.assertRaises(ProvException, lambda: b1.update(doc))

        b1.update(b2)
        self.assertEqual(len(b1.get_records()), 2)
开发者ID:cmaumet,项目名称:prov,代码行数:17,代码来源:test_model.py

示例3: test_document_update_simple

# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import set_default_namespace [as 别名]
    def test_document_update_simple(self):
        d1 = ProvDocument()
        d1.set_default_namespace(EX_URI)
        d1.entity('e')

        b1 = d1.bundle('b1')
        b1.entity('e')

        d2 = ProvDocument()
        d2.set_default_namespace(EX_URI)
        d2.entity('e')

        b1 = d2.bundle('b1')
        b1.entity('e')
        b2 = d2.bundle('b2')
        b2.entity('e')

        self.assertRaises(ProvException, lambda: d1.update(1))

        d1.update(d2)
        self.assertEqual(len(d1.get_records()), 2)
        self.assertEqual(len(d1.bundles), 2)
开发者ID:cmaumet,项目名称:prov,代码行数:24,代码来源:test_model.py

示例4: write_targets_prov

# 需要导入模块: from prov.model import ProvDocument [as 别名]
# 或者: from prov.model.ProvDocument import set_default_namespace [as 别名]
    def write_targets_prov(self, tlist, C, bundle_id):
        #Initialisation
#         cs = b.agent('CrowdScanner')
         
        if self.document_id == -1:
            d = ProvDocument()
            d.add_namespace(AO)
            d.set_default_namespace(self.defaultns % self.game_id)
            if uploadprov:
                provstore_document = self.api.document.create(d, name="Operation%s CrowdScanner" % self.game_id, public=True)
                document_uri = provstore_document.url
                logging.info("prov doc URI: " + str(document_uri))
                self.provfilelist.append(provstore_document.id)
                self.savelocalrecord()
                self.document_id = provstore_document.id
         
        b = ProvDocument()  # Create a new document for this update
        b.add_namespace(AO)
        b.set_default_namespace(self.defaultns % self.game_id)            
            
        # cs to be used with all targets
        cs = b.agent('agent/CrowdScanner', (('prov:type', AO['IBCCAlgo']), ('prov:type', PROV['SoftwareAgent'])))
        
        timestamp = time.time()  # Record the timestamp at each update to generate unique identifiers        
        startTime = datetime.datetime.fromtimestamp(timestamp)
        endTime = startTime
        activity = b.activity('activity/cs/update_report_%s' % timestamp, startTime, endTime)
        activity.wasAssociatedWith(cs)

        #Add target and report entities
        for i, tdata in enumerate(tlist):
            if self.changedtargets[i]==0:
                continue
            
            #Target entity for target i
            tid = int(tdata[0])
            x = tdata[1]
            y = tdata[2]
#             targettype = tdata[3] #don't record here, it will be revealed and recorded by UAVs
            v = int(tdata[4])
            agentids = tdata[7]
            
            targetattributes = {'ao:longitude': x, 'ao:latitude': y, }
            #'ao:asset_type':str(targettype)}
            target_v0 = b.entity('cs/target/'+str(tid)+'.'+str(v), targetattributes)            
            #Post the root report if this is the first version
            if v==0:
                self.targets[tid] = b.entity('cs/target/'+str(tid))
            else:
                try:
                    target_v0.wasDerivedFrom(self.targetversions[tid])
                except KeyError:
                    logging.error("Got a key error for key " + str(tid) + ', which is supposed to be version' + str(v))
            self.targetversions[tid] = target_v0                    
            target_v0.specializationOf(self.targets[tid])
            target_v0.wasAttributedTo(cs)
            
            #Report entities for origins of target i
            for j, r in enumerate(self.target_rep_ids[i]):
                if r not in self.postedreports:
                    Crow = C[r,:]
                    x = Crow[1]
                    y = Crow[2]
                    reptext = tdata[5][j].decode('utf8')
                    # Try to replace unusual characters
                    reptext = reptext.encode('ascii', 'replace')  
                    agentid = agentids[j]
                    
                    reporter_name = 'agent/crowdreporter%s' % agentid
                    b.agent(reporter_name, (('prov:type', AO['CrowdReporter']), ('prov:type', PROV['Person'])))
                    
                    reportattributes = {'ao:longitude': x, 'ao:latitude': y, 'ao:report': reptext}
                    
                    self.postedreports[r] = b.entity('cs/report/'+str(r), reportattributes)
                    self.postedreports[r].wasAttributedTo(reporter_name)
                activity.used(self.postedreports[r])
                target_v0.wasDerivedFrom(self.postedreports[r])
        
        if uploadprov:
            #Invalidate old targets no longer in use
            for i,tid in enumerate(self.targets_to_invalidate):
                target_v = self.targetversions[tid]
                b.wasInvalidatedBy(target_v, activity)
            #Post the document to the server
            #bundle = b.bundle('crowd_scanner')
            bundle_id = 'bundle/csupdate/%s' % timestamp
            self.api.add_bundle(self.document_id, b.serialize(), bundle_id)
开发者ID:edwinrobots,项目名称:HeatMapBCC,代码行数:89,代码来源:maptargets.py


注:本文中的prov.model.ProvDocument.set_default_namespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。