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


Python Graph.close方法代码示例

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


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

示例1: ParserTestCase

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
class ParserTestCase(unittest.TestCase):
    backend = 'default'
    path = 'store'

    def setUp(self):
        self.graph = Graph(store=self.backend)
        self.graph.open(self.path)

    def tearDown(self):
        self.graph.close()

    def testNoPathWithHash(self):
        g = self.graph
        g.parse(data="""\
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
>

<rdfs:Class rdf:about="http://example.org#">
  <rdfs:label>testing</rdfs:label>
</rdfs:Class>

</rdf:RDF>
""", publicID="http://example.org")

        subject = URIRef("http://example.org#")
        label = g.value(subject, RDFS.label)
        self.assertEqual(label, Literal("testing"))
        type = g.value(subject, RDF.type)
        self.assertEqual(type, RDFS.Class)
开发者ID:RDFLib,项目名称:rdflib,代码行数:34,代码来源:test_parser.py

示例2: PychinkoTestCase

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
    class PychinkoTestCase(unittest.TestCase):
        backend = "default"
        tmppath = None

        def setUp(self):
            self.g = Graph(store=self.backend)
            self.tmppath = mkdtemp()
            self.g.open(configuration=self.tmppath)
            self.g.parse("test/a.n3", format="n3")

        def tearDown(self):
            self.g.close()
            shutil.rmtree(tmppath)

        def testPychinko(self):
            rules = []
            for s, p, o in self.g.triples((None, LOG.implies, None)):
                lhs = list(patterns(s))
                rhs = list(patterns(o))
                rules.append(terms.Rule(lhs, rhs, (s, p, o)))
            interp = Interpreter(rules)
            f = Graph()
            f.parse("http://eikeon.com/")
            source = f
            source = self.g
            interp.addFacts(set(facts(source)), initialSet=True)
            interp.run()
开发者ID:RinkeHoekstra,项目名称:rdflib,代码行数:29,代码来源:test_rules.py

示例3: Processor

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
class Processor(object):
    def __init__(self, stream_urls):
        self.client = client.Client(stream_urls,
                                    event_callback=self._handle_event,
                                    error_callback=self._handle_error,
                                    separate_events=False)
        self.triple_store = Graph('Sleepycat',
                                  'http://www.it.uc3m.es/jaf/ns/slog/db')
        self.db_dir = 'dbdir'

    def start(self, loop=False):
        self.triple_store.open(self.db_dir)
        self.client.start(loop=loop)

    def stop(self):
        self.triple_store.close()
        self.client.stop()

    def _handle_error(self, message, http_error=None):
        pass

    def _handle_event(self, evs):
        print('Received {} events.'.format(len(evs)))
        for event in evs:
            self.triple_store += event.body
        print(len(self.triple_store))
开发者ID:jfisteus,项目名称:ztreamy,代码行数:28,代码来源:processor.py

示例4: PostgreSQLStoreTests

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
class PostgreSQLStoreTests(unittest.TestCase):
    storetest = True
    store_name = "PostgreSQL"
    path = configString
    create = True

    def setUp(self):
        self.graph = Graph(store=self.store_name)
        self.graph.open(self.path, create=self.create)

    def tearDown(self):
        self.graph.destroy(self.path)
        self.graph.close()
        import os

        if hasattr(self, "path") and self.path is not None:
            if os.path.exists(self.path):
                if os.path.isdir(self.path):
                    for f in os.listdir(self.path):
                        os.unlink(self.path + "/" + f)
                    os.rmdir(self.path)
                elif len(self.path.split(":")) == 1:
                    os.unlink(self.path)
                else:
                    os.remove(self.path)

    def test_PostgreSQL_testN3_store(self):
        testN3Store("PostgreSQL", configString)
开发者ID:bcroq,项目名称:rdflib-postgresql,代码行数:30,代码来源:test_postgresql.py

示例5: test_different_uris

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_different_uris():
    """ Pass different URIs to __init__() and to open().
    """

    store = ProxyStore(identifier="http://localhost:1234/foo")
    graph = Graph(store=store)
    graph.open({PS_CONFIG_URI: "http://localhost:1234/foo/group1/"})
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:10,代码来源:test_rdfrest_proxystore.py

示例6: test_no_uri

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_no_uri():
    """ Pass no URI to __init__() nor to open().
    """

    store = ProxyStore()
    graph = Graph(store=store)
    graph.open({})
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:10,代码来源:test_rdfrest_proxystore.py

示例7: test_05_persist

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
	def test_05_persist(self):
		graph = Graph("SWIStore", identifier="test")
		assert not graph.store.attached
		graph.open("test.db")
		assert graph.store.attached
		graph.parse(cofog_test)
		stat("test.db")
		graph.close()
开发者ID:pombredanne,项目名称:swipy,代码行数:10,代码来源:test_10_store.py

示例8: test_identifier_no_open

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_identifier_no_open():
    """ Pass the URI as identifier to __init__() but does not explicitely
        call open(). Should be OK.
    """
    store = ProxyStore(identifier="http://localhost:1234/foo")
    graph = Graph(store=store)
    gs = graph.serialize()
    #print gs
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:11,代码来源:test_rdfrest_proxystore.py

示例9: test_no_uri_no_open

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_no_uri_no_open():
    """ Nothing passed to __init__(), and open() is not called either.
        Try to manipulate the graph, should trigger an error.
    """

    store = ProxyStore()
    graph = Graph(store=store)
    gs = graph.serialize()
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:11,代码来源:test_rdfrest_proxystore.py

示例10: test_uri_with_wrong_credentials_in_init

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_uri_with_wrong_credentials_in_init():
    """ Pass an URI to __init__() and wrong credentials in configuration.
    """

    store = ProxyStore(configuration={PS_CONFIG_USER: "user",
                                      PS_CONFIG_PWD: "wrong-pwd"},
                       identifier="http://localhost:1234/foo")
    graph = Graph(store=store)
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:11,代码来源:test_rdfrest_proxystore.py

示例11: test_no_uri

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_no_uri():
    """ Pass no URI to __init__() nor to open().
    """
    with assert_raises(StoreIdentifierError):

        store = ProxyStore()
        graph = Graph(store=store)
        graph.open({})
        graph.close()
开发者ID:ktbs,项目名称:ktbs,代码行数:11,代码来源:test_rdfrest_proxystore.py

示例12: test_uri_with_good_credentials_in_init

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_uri_with_good_credentials_in_init():
    """ Pass an URI to __init__() and good credentials in configuration.
        Should be OK.
    """
    http = httplib2.Http()
    http.add_credentials("user", "pwd")
    store = ProxyStore(configuration={PS_CONFIG_HTTP_CX: http},
                       identifier="http://localhost:1234/foo/")
    graph = Graph(store=store)
    graph.close()
开发者ID:ktbs,项目名称:ktbs,代码行数:12,代码来源:test_rdfrest_proxystore.py

示例13: test_uri_with_good_credentials_in_open

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_uri_with_good_credentials_in_open():
    """ Pass an URI to __init__() and good credentials in configuration.
        Should be OK.
    """

    store = ProxyStore(identifier="http://localhost:1234/foo")
    graph = Graph(store=store)
    graph.open(configuration={PS_CONFIG_USER: "user",
                              PS_CONFIG_PWD: "pwd"})
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:12,代码来源:test_rdfrest_proxystore.py

示例14: test_06_retract

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [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()
开发者ID:pombredanne,项目名称:swipy,代码行数:12,代码来源:test_10_store.py

示例15: test_identifier_no_configuration

# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import close [as 别名]
def test_identifier_no_configuration():
    """ Pass the URI as identifier to __init__() then call open() with no
        configuration parameter.
    """

    store = ProxyStore(identifier="http://localhost:1234/foo")
    graph = Graph(store=store)
    graph.open({})
    gs = graph.serialize()
    #print gs
    graph.close()
开发者ID:fderbel,项目名称:ktbs,代码行数:13,代码来源:test_rdfrest_proxystore.py


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