示例#1
0
文件: utils.py 项目: mathspanda/CU-KG
def write_quad(subject, predicate, object):
    client = CayleyClient()
    g = CayleyWrite()
    g.append(subject, predicate, object)
    status_code, result = client.write(g)
    if status_code == 200:
        return True
    return False
示例#2
0
文件: utils.py 项目: mathspanda/CU-KG
def get_direct_relation(name):
    client = CayleyClient()
    g = CayleyGraphObject()
    query_data = g.V(name) \
        .Tag('subject') \
        .Out('null', 'predicate') \
        .Tag('object') \
        .All()
    status_code, result = client.query(query_data)
    if status_code == 200 and result['result'] is not None:
        return True, result
    return False, None
示例#3
0
    def test_query(self):
        client = CayleyClient()
        g = CayleyGraphObject()
        query = g.V() \
            .Tag('subject') \
            .Out('null', 'predicate') \
            .Tag('object') \
            .All()
        status, result = client.query(query)

        print result
        self.assertEqual(status, 200)
        self.assertTrue(len(result) > 0)