work.py 文件源码

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

项目:bibcat 作者: KnowledgeLinks 项目源码 文件源码
def run(self):
        """Runs Collection Generator"""
        result = requests.post(self.triplestore_url,
                data={"query": GET_AVAILABLE_COLLECTIONS,
                      "format": "json"})
        if result.status_code > 399:
            raise WorkError("Failed to run sparql query")

        bindings = result.json().get('results').get('bindings')
        for row in bindings:
            instance_uri = rdflib.URIRef(row.get('instance').get('value'))
            org_uri = rdflib.URIRef(row.get('org').get('value'))
            item_uri = rdflib.URIRef(row.get('item').get('value'))
            label = rdflib.Literal(row.get('label').get('value'))
            #! Should check for language in label
            collections = self.__handle_collections__(
                instance=instance_uri, 
                item=item_uri,
                organization=org_uri, 
                rdfs_label=label)
            # Now remove existing BNode's properties from the BF Instance
            delete_result = requests.post(
                self.triplestore_url,
                data=DELETE_COLLECTION_BNODE.format(instance_uri),
                headers={"Content-Type": "application/sparql-update"})
            if delete_result.status_code > 399:
                raise WorkError("Cannot Delete Collection blank nodes for {}\n{}".format(
                    instance_uri, delete_result.text))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号