本文整理汇总了Python中rdflib.graph.Graph.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.remove方法的具体用法?Python Graph.remove怎么用?Python Graph.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.graph.Graph
的用法示例。
在下文中一共展示了Graph.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (getattr(settings, 'SPARQL_DATA'),
self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
self.factory = RequestFactory()
def tearDown(self):
for res in self.g:
self.g.remove(res)
def test_PUT(self):
#self.test_insert_anotation()
graph = format_graphIRI('submitted')
request = self.factory.put('/endpoint?graph=%s' % graph,
data = turtle_usecase1,
content_type = 'text/turtle')
response = endpoint(request)
self.assert_(response.status_code in [200, 204], "HTTPResponse has status_code: %s"
% response.status_code)
示例2: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (SPARQL_DATA, self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
'''
SELECT Distinct ?g ?s ?p ?o
WHERE {
GRAPH ?g {
?s ?p ?o .
}
}
'''
def tearDown(self):
for res in self.g:
self.g.remove(res)
def test_insert_turtle(self):
tmp_g = insert_rdf(turtle_data, 'text/turtle', graph=ANNO_SUBMITTED)
final_doc = tmp_g.serialize()
print tmp_g.serialize()
self.assertFalse('localhost' in final_doc, "Error ingesting turtle")
self.assertFalse('annoID' in final_doc, "Error ingesting turtle")
self.assertFalse('bodyID' in final_doc, "Error ingesting turtle")
self.assertFalse('chnode: <nodeURI/>' in final_doc, "Error ingesting turtle")
self.assertFalse('chnode:annoID' in final_doc, "Error ingesting turtle")
self.assertFalse('chnode:bodyID' in final_doc, "Error ingesting turtle")
def test_insert_jsonld(self):
tmp_g = insert_rdf(jsonld_data, 'application/ld+json', graph=ANNO_SUBMITTED)
final_doc = tmp_g.serialize()
print tmp_g.serialize()
self.assertFalse('localhost' in final_doc, "Error ingesting jsonld")
self.assertFalse('annoID' in final_doc, "Error ingesting jsonld")
self.assertFalse('bodyID' in final_doc, "Error ingesting jsonld")
self.assertFalse('localhost/bodyID' in final_doc, "Error ingesting jsonld")
self.assertFalse('localhost/annoID' in final_doc, "Error ingesting jsonld")
def test_insert_rdf(self):
tmp_g = insert_rdf(rdf_data, 'application/rdf+xml', graph=ANNO_SUBMITTED)
final_doc = tmp_g.serialize()
print tmp_g.serialize()
self.assertFalse('localhost' in final_doc, "Error ingesting rdf")
self.assertFalse('annoID' in final_doc, "Error ingesting rdf")
self.assertFalse('bodyID' in final_doc, "Error ingesting rdf")
self.assertFalse('localhost/bodyID' in final_doc, "Error ingesting rdf")
self.assertFalse('localhost/annoID' in final_doc, "Error ingesting rdf")
def test_formatNode(self):
tmpURIRef = URIRef('http://localhost/annoID')
res = _formatNodeURIRef(tmpURIRef, 'abcdef', '123456')
self.assertFalse('annoID' in res, "Error")
示例3: test_06_retract
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def test_06_retract(self):
graph = Graph("SWIStore", identifier="test")
graph.open("test.db")
ntriples = len(list(graph.triples((None, RDFS.label, None))))
assert ntriples > 0
graph.remove((None, RDFS.label, None))
ntriples = len(list(graph.triples((None, RDFS.label, None))))
assert ntriples == 0
graph.store.unload(graph)
graph.close()
示例4: create_project
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def create_project(g):
"""Creates a project in the database (and the metadata cache) from an input graph"""
print "Here 1"
query = g.query("""SELECT ?uri ?user
WHERE {
?user perm:hasPermissionOver ?uri .
?user rdf:type foaf:Agent .
}""", initNs=ns)
print "Here 2"
for uri in g.subjects(NS.rdf.type, NS.dm.Project):
print "Here 3"
user = g.value(None, NS.perm.hasPermissionOver, uri)
if user:
print "Here 3.1"
user_obj = User.objects.get(username=user.split('/')[-1])
print "Here 3.2"
project_identifier = uris.uri('semantic_store_projects', uri=uri)
print "Here 3.3"
project_g = Graph(store=rdfstore(), identifier=project_identifier)
print "Here 4"
for text_uri in g.subjects(NS.rdf.type, NS.dcmitype.Text):
text_graph = Graph()
text_graph += g.triples((text_uri, None, None))
print "Here 4.1"
if user:
project_texts.update_project_text(text_graph, uri, text_uri, user_obj)
print "Here 5"
for t in g:
project_g.add(t)
for text_uri in g.subjects(NS.rdf.type, NS.dcmitype.Text):
project_g.remove((text_uri, NS.cnt.chars, None))
url = uris.url('semantic_store_projects', uri=uri)
project_g.set((uri, NS.dcterms['created'], Literal(datetime.utcnow())))
print "before user"
if user:
print "user is true"
project_g.remove((user, None, None))
username = user.split("/")[-1]
permissions.grant_full_project_permissions(username, uri)
add_project_types(project_g, uri)
build_project_metadata_graph(uri)
print "Successfully created project with uri " + uri
示例5: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (getattr(settings, 'SPARQL_DATA'),
self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
self.factory = RequestFactory()
def tearDown(self):
for res in self.g:
self.g.remove(res)
if hasattr(self, 'user'):
self.user.delete()
def test_advance_status(self):
new_state = 'stable'
response = test_insert_anotation(self)
anno_uri = extract_annotation_uri(response.content)
annoid = anno_uri[anno_uri.rfind('/') + 1 : ]
self.assertIsNotNone(annoid, "Did not insert the annotation")
data = {'annotation': annoid,
'toState': new_state}
response = advance_status(test_advance_status(self, json.dumps(data)))
'''
Need to verify better the triple has been moved
for example using the (TBD)
'''
self.assert_(response.status_code == 200, "HTTPResponse has status_code: %s" % response.status_code)
#self.assert_(('%s a rdfg:Graph' % (new_state)) in response.content, "Response content does not return the correct state")
def test_advance_status_wrong_body(self):
new_state = 'stable'
response = test_insert_anotation(self)
anno_uri = extract_annotation_uri(response.content)
annoid = anno_uri[anno_uri.rfind('/') + 1 : ]
self.assertIsNotNone(annoid, "Did not insert the annotation")
data = {'annotation': annoid, 'toState': new_state}
response = advance_status(test_advance_status(self,
url='/advance_status?' + urlencode(data),
data=json.dumps(data)))
示例6: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (SPARQL_DATA, self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
def tearDown(self):
for res in self.g:
self.g.remove(res)
def test_usecase_1(self):
tmp_g = insert_rdf(turtle_usecase1, 'text/turtle', graph=ANNO_SUBMITTED)
print tmp_g.serialize()
示例7: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (getattr(settings, 'SPARQL_DATA'),
self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
self.factory = RequestFactory()
users = User.objects.filter(username = 'Alberto Sordi')
if users.count() == 0:
self.user = User.objects.create_user('Alberto Sordi', '[email protected]', 'ammericano')
def tearDown(self):
for res in self.g:
self.g.remove(res)
if hasattr(self, 'user'):
self.user.delete()
def test_insert_anotation(self):
response = insert(self.factory.post('/insert/annotation',
content_type='text/turtle',
data=turtle_usecase1,
HTTP_ACCEPT = 'application/rdf+xml'))
self.assert_(response.status_code == 200, "HTTPResponse has status_code: %s" % response.status_code)
anno_uri = self.extract_annotation_uri(response.content)
annoid = anno_uri[anno_uri.rfind('/') + 1 : ]
request = self._prepare_get('/resource/%s' % annoid)
request.META['HTTP_ACCEPT'] = "text/html"
response = process_page(request, resource_id = annoid)
print response
return response
def _prepare_get(self, url):
request = self.factory.get(url)
request.user = self.user
return request
'''
示例8: test_shacl_shapes
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def test_shacl_shapes():
"""Test SHACL shapes that should fail SHACL validation."""
# We start by constructing a tree that consists of a single node.
g = Graph()
node1 = BNode()
g.add((node1, RDF.type, CDAO_Node))
save_graph_and_validate(g, False)
# If we add a non-CDAO_Node as a child, we should fail.
non_node = BNode()
g.add((node1, CDAO_hasChild, non_node))
save_graph_and_validate(g, False)
g.remove((node1, CDAO_hasChild, non_node))
# If we add another node with another CDAO_Node, we should fail.
node2 = BNode()
g.add((node2, RDF.type, CDAO_Node))
g.add((node1, RDFS.subClassOf, node2))
save_graph_and_validate(g, False)
g.remove((node1, RDFS.subClassOf, node2))
# But if we add another node as a CDAO_hasChild, we should succeed.
# TODO: This currently fails, since node2 does not have a CDAO_hasChild
# to another node.
g.add((node1, CDAO_hasChild, node2))
save_graph_and_validate(g, False)
g.add((node2, CDAO_hasChild, node1))
save_graph_and_validate(g, True)
# If we add a third node as a sibling, that should be fine too.
# TODO: We should check to see if siblings mark each other.
node3 = BNode()
g.add((node3, RDF.type, CDAO_Node))
g.add((node3, phyloref_has_Sibling, node2))
save_graph_and_validate(g, True)
# No node should be the child of itself.
g.add((node2, CDAO_hasChild, node2))
save_graph_and_validate(g, False)
示例9: testRemoveInMultipleContexts
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def testRemoveInMultipleContexts(self):
c1 = self.c1
c2 = self.c2
triple = (self.pizza, self.hates, self.tarek)
self.addStuffInMultipleContexts()
# triple should be still in store after removing it from c1 + c2
self.assertIn(triple, self.graph)
graph = Graph(self.graph.store, c1)
graph.remove(triple)
self.assertIn(triple, self.graph)
graph = Graph(self.graph.store, c2)
graph.remove(triple)
self.assertIn(triple, self.graph)
self.graph.remove(triple)
# now gone!
self.assertNotIn(triple, self.graph)
# add again and see if remove without context removes all triples!
self.addStuffInMultipleContexts()
self.graph.remove(triple)
self.assertNotIn(triple, self.graph)
示例10: GraphTest
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class GraphTest(unittest.TestCase):
backend = 'default'
path = 'store'
def setUp(self):
self.store = Graph(store=self.backend)
self.store.open(self.path)
self.remove_me = (BNode(), RDFS.label, Literal("remove_me"))
self.store.add(self.remove_me)
def tearDown(self):
self.store.close()
def testAdd(self):
subject = BNode()
self.store.add((subject, RDFS.label, Literal("foo")))
def testRemove(self):
self.store.remove(self.remove_me)
self.store.remove((None, None, None))
def testTriples(self):
for s, p, o in self.store:
pass
示例11: remove_project_text
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def remove_project_text(project_uri, text_uri):
# Correctly format project uri and get project graph
project_uri = uris.uri('semantic_store_projects', uri=project_uri)
project_g = Graph(rdfstore(), identifier=project_uri)
project_metadata_g = Graph(rdfstore(), identifier=uris.project_metadata_graph_identifier(p_uri))
# Make text uri a URIRef (so Graph will understand)
text_uri = URIRef(text_uri)
with transaction.commit_on_success():
for t in specific_resources_subgraph(project_g, text_uri, project_uri):
project_g.remove(t)
for t in project_g.triples((text_uri, None, None)):
# Delete triple about text from project graph
project_g.remove(t)
project_metadata_g.remove(t)
project_g.remove((URIRef(project_uri), NS.ore.aggregates, text_uri))
for text in Text.objects.filter(identifier=text_uri, valid=True).only('valid'):
text.valid = False
text.save()
示例12: Test
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class Test(unittest.TestCase):
def setUp(self):
self.store = CharmeMiddleware.get_store(debug = True)
self.graph = 'submitted'
self.identifier = '%s/%s' % (SPARQL_DATA, self.graph)
self.g = Graph(store=self.store, identifier=self.identifier)
self.factory = RequestFactory()
def tearDown(self):
for res in self.g:
self.g.remove(res)
def test_insert_anotation(self):
response = insert(self.factory.post('/insert/annotation',
content_type='text/turtle',
data=turtle_usecase1))
self.assert_(response.status_code == 200, "HTTPResponse has status_code: %s" % response.status_code)
return response
def test_GET(self):
self.test_insert_anotation()
graph = format_graphIRI('submitted')
for accept in FORMAT_MAP.values():
request = self.factory.get('/endpoint', data = {'graph': graph},
HTTP_ACCEPT = accept)
response = endpoint(request)
self.assert_(response.status_code in [200, 204], "HTTPResponse has status: %s"
% response.status_code)
self.assert_('http://data.gov.uk//dataset/index-of-multiple-deprivation'
in response.content, "Cannot serialize %s" % accept)
def test_GET_406(self):
self.test_insert_anotation()
graph = format_graphIRI('submitted')
request = self.factory.get('/endpoint', data = {'graph': graph},
HTTP_ACCEPT = 'fake')
response = endpoint(request)
self.assert_(response.status_code in [406], "HTTPResponse has status: %s"
% response.status_code)
def test_GET_default(self):
self.test_insert_anotation()
graph = 'default'
for accept in FORMAT_MAP.values():
request = self.factory.get('/endpoint', data = {'graph': graph},
HTTP_ACCEPT = accept)
response = endpoint(request)
self.assert_(response.status_code in [200, 204], "HTTPResponse has status: %s"
% response.status_code)
self.assert_('http://data.gov.uk//dataset/index-of-multiple-deprivation'
in response.content, "Cannot serialize %s" % accept)
def test_GET_default_2(self):
self.test_insert_anotation()
for accept in FORMAT_MAP.values():
request = self.factory.get('/endpoint', data = {},
HTTP_ACCEPT = accept)
response = endpoint(request)
self.assert_(response.status_code in [200, 204], "HTTPResponse has status: %s"
% response.status_code)
self.assert_('http://data.gov.uk//dataset/index-of-multiple-deprivation'
in response.content, "Cannot serialize %s" % accept)
示例13: GraphMemoryTestCase
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
class GraphMemoryTestCase(unittest.TestCase):
store_name = 'Agamemnon'
settings1 = {
'agamemnon.keyspace' : 'memory',
'agamemnon.host_list' : '["localhost:9160"]',
'agamemnon.rdf_namespace_base' : 'http://www.example.org/rdf/',
}
settings2 = {
'agamemnon.keyspace' : 'memory',
'agamemnon.host_list' : '["localhost:9160"]',
'agamemnon.rdf_namespace_base' : 'http://www.example.org/rdf/',
}
def setUp(self):
self.graph1 = Graph(store=self.store_name)
self.graph2 = Graph(store=self.store_name)
self.graph1.open(self.settings1, True)
self.graph2.open(self.settings2, True)
self.oNS = Namespace("http://www.example.org/rdf/things#")
self.sNS = Namespace("http://www.example.org/rdf/people#")
self.pNS = Namespace("http://www.example.org/rdf/relations/")
self.graph1.bind('people',self.sNS)
self.graph1.bind('relations',self.pNS)
self.graph1.bind('things',self.oNS)
self.graph2.bind('people',self.sNS)
self.graph2.bind('relations',self.pNS)
self.graph2.bind('things',self.oNS)
self.michel = self.sNS.michel
self.tarek = self.sNS.tarek
self.alice = self.sNS.alice
self.bob = self.sNS.bob
self.likes = self.pNS.likes
self.hates = self.pNS.hates
self.named = self.pNS.named
self.pizza = self.oNS.pizza
self.cheese = self.oNS.cheese
def tearDown(self):
self.graph1.close()
self.graph2.close()
def addStuff(self,graph):
graph.add((self.tarek, self.likes, self.pizza))
graph.add((self.tarek, self.likes, self.cheese))
graph.add((self.michel, self.likes, self.pizza))
graph.add((self.michel, self.likes, self.cheese))
graph.add((self.bob, self.likes, self.cheese))
graph.add((self.bob, self.hates, self.pizza))
graph.add((self.bob, self.hates, self.michel)) # gasp!
graph.add((self.bob, self.named, Literal("Bob")))
def removeStuff(self,graph):
graph.remove((None, None, None))
def testBind(self):
store = self.graph1.store
self.assertEqual(store.namespace(""), Namespace("http://www.example.org/rdf/"))
self.assertEqual(store.namespace('people'),self.sNS)
self.assertEqual(store.namespace('relations'),self.pNS)
self.assertEqual(store.namespace('things'),self.oNS)
self.assertEqual(store.namespace('blech'),None)
self.assertEqual("", store.prefix(Namespace("http://www.example.org/rdf/")))
self.assertEqual('people',store.prefix(self.sNS))
self.assertEqual('relations',store.prefix(self.pNS))
self.assertEqual('things',store.prefix(self.oNS))
self.assertEqual(None,store.prefix("blech"))
self.assertEqual(len(list(self.graph1.namespaces())), 7)
def testRelationshipToUri(self):
uri = self.graph1.store.rel_type_to_ident('likes')
self.assertEqual(uri, URIRef("http://www.example.org/rdf/likes"))
uri = self.graph1.store.rel_type_to_ident('emotions:likes')
self.assertEqual(uri, URIRef("emotions:likes"))
self.graph1.bind('emotions','http://www.emo.org/')
uri = self.graph1.store.rel_type_to_ident('emotions:likes')
self.assertEqual(uri, URIRef("http://www.emo.org/likes"))
def testNodeToUri(self):
node = self.graph1.store._ds.create_node('blah', 'bleh')
uri = self.graph1.store.node_to_ident(node)
self.assertEqual(uri, URIRef("http://www.example.org/rdf/blah#bleh"))
self.graph1.bind("bibble", "http://www.bibble.com/rdf/bibble#")
node = self.graph1.store._ds.create_node('bibble', 'babble')
uri = self.graph1.store.node_to_ident(node)
self.assertEqual(uri, URIRef("http://www.bibble.com/rdf/bibble#babble"))
def testUriToRelationship(self):
rel_type = self.graph1.store.ident_to_rel_type(URIRef("http://www.example.org/rdf/likes"))
self.assertEqual(rel_type, 'likes')
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
#.........这里部分代码省略.........
'''
for place in rss.getElementsByTagName('place'):
name1 = place.getElementsByTagName('name1')[0].firstChild.nodeValue
blogger_id1 = place.getElementsByTagName('blogger-id')[0].firstChild.nodeValue
title1 = place.getElementsByTagName('title')[0].firstChild.nodeValue
url1 = place.getElementsByTagName('url')[0].firstChild.nodeValue
date1 = place.getElementsByTagName('date')[0].firstChild.nodeValue
expense = place.getElementsByTagName('expense')[0].firstChild.nodeValue
blog = self.nsDict['blog']
foaf = self.nsDict['foaf']
dcterms = self.nsDict['dcterms']
self.graph.add((blog,blogger_id1,Literal(blogger_id1)))
self.graph.add((blog[blogger_id1],foaf['name'],Literal(name1)))
self.graph.add((blog[blogger_id1],dcterms['title'],Literal(title1)))
self.graph.add((blog[blogger_id1],dcterms['date'],Literal(date1)))
'''
self.graph.commit()
def open_store(self):
default_graph_uri = "http://rdflib.net/rdfstore"
# open existing store or create new one
#store = getStore() # if store does not exist, then new store returned
# RDF store section:
configString = "/var/tmp/rdfstore"
# Get the Sleepycat plugin.
store = plugin.get('Sleepycat', Store)('rdfstore')
# Open previously created store, or create it if it doesn't exist yet
path = mkdtemp()
rt = store.open('rdfstore', create=False)
#print rt
#print path
if rt == NO_STORE:
print "Creating new store"
# There is no underlying Sleepycat infrastructure, create it
store.open('rdfstore', create=True)
else:
print "store exists "
#assert rt == VALID_STORE, "The underlying store is corrupt"
self.graph = Graph(store,identifier = URIRef(default_graph_uri))
self.build_graph()
'''
print_RDF_triples(graph)
#print_RDF_XML(graph)
graph.commit()
#create_RDF_File(graph)
graph.close(commit_pending_transaction=True)
'''
def run_Query(self,queryString):
qres = self.graph.query(queryString,
initNs=dict(foaf=Namespace("http://xmlns.com/foaf/0.1/"),
blog = Namespace('http://rdflib.net/blog/'),
blogger_id = Namespace('http://rdflib.net/blog/blogger_id/'))
)
for row in qres.result:
print row
def print_RDF_XML(self):
#print graph.serialize(format="pretty-xml")
print self.graph.serialize()
def print_RDF_triples(self):
print "Triples in graph after add: ", len(graph)
#Iterate over triples in graph and print them out.
print "--- printing raw triples ---"
for s, p, o in self.graph:
print s, p, o
def print_RDF_Maker(self):
# For each foaf:Project in the self.graph print out its maker.
print "--- printing MAKERS ---"
for game in self.graph.subjects(RDF.type, FOAF["Project"]):
for madeby in self.graph.objects(game, FOAF["maker"]):
print madeby
def removeFromStore(self):
rdflib = Namespace('http://rdflib.net/games/')
self.graph.bind("game", "http://rdflib.net/games/")
self.graph.remove((rdflib['game:2'], rdflib['name'], Literal('Ignition')))
self.graph.commit()
#str(graph)
def sample_query(self, querystring):
print "Query enter"
processor = plugin.get('sparql', rdflib.query.Processor)(self.graph)
result = plugin.get('sparql', rdflib.query.Result)
ns = dict(self.graph.namespace_manager.namespaces())
return result(processor.query(querystring, initNs=ns))
示例15: tearDown
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import remove [as 别名]
def tearDown(self):
identifier = '%s/%s' % (SPARQL_DATA, ANNO_SUBMITTED)
g = Graph(store=self.store, identifier=identifier)
for res in g:
g.remove(res)