Ejemplo n.º 1
0
 def __init__(self, reader=None, writer=None):
     GraphSONMessageSerializer.__init__(
         self, reader, writer, b"application/vnd.gremlin-v2.0+json")
     if not reader:
         self._graphson_reader = graphsonV2d0.GraphSONReader()
     if not writer:
         self._graphson_writer = graphsonV2d0.GraphSONWriter()
     self.standard = Standard(self._graphson_writer)
     self.traversal = Traversal(self._graphson_writer)
Ejemplo n.º 2
0
import collections
try:
    import ujson as json
except ImportError:
    import json

from gremlin_python.structure.io import graphsonV2d0 as graphson
from hobgoblin.element import Vertex, Edge, VertexProperty
from hobgoblin.manager import ListVertexPropertyManager

writer = graphson.GraphSONWriter()

AdjList = collections.namedtuple("AdjList", "vertex inE outE")

vp_id = 10


def dump(fpath, *adj_lists, mode="w"):
    """Convert Hobgoblin elements to GraphSON"""
    with open(fpath, mode) as f:
        for adj_list in adj_lists:
            dumped = dumps(adj_list)
            f.write(dumped + '\n')


def dumps(adj_list):
    """Convert Hobgoblin elements to GraphSON"""
    vertex = _prep_vertex(adj_list.vertex)
    for inE in adj_list.inE:
        prepped = _prep_edge(inE, "inV")
        label = inE.__label__
Ejemplo n.º 3
0
 def __init__(self):
     reader = graphsonV2d0.GraphSONReader()
     writer = graphsonV2d0.GraphSONWriter()
     version = b"application/vnd.gremlin-v2.0+json"
     super(GraphSONSerializersV2d0, self).__init__(reader, writer, version)