本文整理汇总了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