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

from gremlin_python.structure.io import graphsonV3d0 as graphson
from goblin.element import Vertex, Edge, VertexProperty
from goblin.manager import ListVertexPropertyManager

writer = graphson.GraphSONWriter()

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

vp_id = 10


def dump(fpath, *adj_lists, mode="w"):
    """Convert Goblin 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 Goblin elements to GraphSON"""
    vertex = _prep_vertex(adj_list.vertex)
    if adj_list.inE:
        for inE in adj_list.inE:
            prepped = _prep_edge(inE, "inV")