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


Python ConjunctiveGraph.sync方法代码示例

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


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

示例1: TripleStore

# 需要导入模块: from rdflib import ConjunctiveGraph [as 别名]
# 或者: from rdflib.ConjunctiveGraph import sync [as 别名]
class TripleStore(object):
    """ A root object to supply store connectivity to view code """
    def __init__(self, request):
        self.request = request

        q = self.request.registry.queryUtility
        self.logger = q(IDebugLogger)

        if self.request.registry.settings:
            if (self.request.registry.settings.get('store_type',None) == 'talis'):
                # Configure a connection to the talis store
                self.store = Talis(self.request.registry.settings['talis_store'],
                               self.request.registry.settings['talis_user'],
                               self.request.registry.settings['talis_password'])
                self.debug_sparql = self.request.registry.settings['debug_sparql']
            else:
                self.store = Graph()
                self.debug_sparql = False
        else:
            self.store = Graph()
            self.debug_sparql = False
              
    def query(self, sparql, format='json'):
        
        if self.debug_sparql:
            msg = (sparql)
            self.logger and self.logger.debug(msg)
        
        #if isinstance(self.store, Graph) and "DESCRIBE" in sparql:
        #    """ rdflib currently requires a hack for describe queries involving literals """
        #    res = [x for x in self.store if not 'http://plings.net/' in str(x[0])]
        ##    import pdb
        #    pdb.set_trace()
        #else:
        res = self.store.query(sparql)
        
        # If we're working with a local rdflib graph we'll need to delve to get the results
        if isinstance(res, SPARQLQueryResult):
            return res.result
        else:
            return res
        
    def sync(self):
        if self.request.registry.settings['store_type'] == 'talis':
            self.store.sync()
        else:
            pass
开发者ID:neontribe,项目名称:PlingBack,代码行数:49,代码来源:resources.py


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