sparqlstore.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Meiji 作者: GiovanniBalestrieri 项目源码 文件源码
def remove(self, spo, context):
        """ Remove a triple from the store """
        if not self.endpoint:
            raise Exception("UpdateEndpoint is not set - call 'open'")

        (subject, predicate, obj) = spo
        if not subject:
            subject = Variable("S")
        if not predicate:
            predicate = Variable("P")
        if not obj:
            obj = Variable("O")

        nts = self.node_to_sparql
        triple = "%s %s %s ." % (nts(subject), nts(predicate), nts(obj))
        if self._is_contextual(context):
            cid = nts(context.identifier)
            q = "DELETE { GRAPH %s { %s } } WHERE { GRAPH %s { %s } }" % (
                cid, triple,
                cid, triple)
        else:
            q = "DELETE { %s } WHERE { %s } " % (triple, triple)
        self._transaction().append(q)
        if self.autocommit:
            self.commit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号