gremlinpython 4.0.0b2__py3-none-any.whl → 4.0.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gremlin_python/__init__.py +1 -1
- gremlin_python/driver/aiohttp/transport.py +257 -85
- gremlin_python/driver/auth.py +46 -21
- gremlin_python/driver/client.py +89 -61
- gremlin_python/driver/connection.py +123 -19
- gremlin_python/driver/driver_remote_connection.py +16 -39
- gremlin_python/driver/{transport.py → exceptions.py} +10 -24
- gremlin_python/driver/http_request.py +65 -0
- gremlin_python/driver/request.py +3 -2
- gremlin_python/driver/resultset.py +11 -5
- gremlin_python/driver/serializer.py +50 -130
- gremlin_python/driver/transaction.py +178 -0
- gremlin_python/driver/useragent.py +1 -1
- gremlin_python/process/graph_traversal.py +210 -93
- gremlin_python/process/traversal.py +114 -51
- gremlin_python/structure/graph.py +450 -5
- gremlin_python/structure/io/graphbinaryV4.py +177 -37
- {gremlinpython-4.0.0b2.dist-info → gremlinpython-4.0.0.dev1.dist-info}/METADATA +7 -5
- gremlinpython-4.0.0.dev1.dist-info/RECORD +33 -0
- {gremlinpython-4.0.0b2.dist-info → gremlinpython-4.0.0.dev1.dist-info}/WHEEL +1 -1
- gremlin_python/driver/protocol.py +0 -175
- gremlin_python/structure/io/graphsonV4.py +0 -599
- gremlinpython-4.0.0b2.dist-info/RECORD +0 -33
- {gremlinpython-4.0.0b2.dist-info → gremlinpython-4.0.0.dev1.dist-info}/licenses/LICENSE +0 -0
- {gremlinpython-4.0.0b2.dist-info → gremlinpython-4.0.0.dev1.dist-info}/licenses/NOTICE +0 -0
- {gremlinpython-4.0.0b2.dist-info → gremlinpython-4.0.0.dev1.dist-info}/top_level.txt +0 -0
|
@@ -1,599 +0,0 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
|
12
|
-
# software distributed under the License is distributed on an
|
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
# KIND, either express or implied. See the License for the
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
17
|
-
import base64
|
|
18
|
-
import calendar
|
|
19
|
-
import datetime
|
|
20
|
-
import json
|
|
21
|
-
import uuid
|
|
22
|
-
import math
|
|
23
|
-
from collections import OrderedDict
|
|
24
|
-
from decimal import *
|
|
25
|
-
import logging
|
|
26
|
-
from datetime import timedelta
|
|
27
|
-
|
|
28
|
-
from aenum import Enum
|
|
29
|
-
from isodate import parse_duration, duration_isoformat
|
|
30
|
-
|
|
31
|
-
from gremlin_python import statics
|
|
32
|
-
from gremlin_python.statics import FloatType, BigDecimal, ShortType, IntType, LongType, TypeType, DictType, ListType, SetType, SingleByte, SingleChar, bigdecimal
|
|
33
|
-
from gremlin_python.process.traversal import Direction, P, TextP, Traversal, Traverser, TraversalStrategy, T
|
|
34
|
-
from gremlin_python.structure.graph import Edge, Property, Vertex, VertexProperty, Path
|
|
35
|
-
from gremlin_python.structure.io.util import HashableDict, SymbolUtil
|
|
36
|
-
|
|
37
|
-
log = logging.getLogger(__name__)
|
|
38
|
-
|
|
39
|
-
# When we fall back to a superclass's serializer, we iterate over this map.
|
|
40
|
-
# We want that iteration order to be consistent, so we use an OrderedDict,
|
|
41
|
-
# not a dict.
|
|
42
|
-
_serializers = OrderedDict()
|
|
43
|
-
_deserializers = {}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class GraphSONTypeType(type):
|
|
47
|
-
def __new__(mcs, name, bases, dct):
|
|
48
|
-
cls = super(GraphSONTypeType, mcs).__new__(mcs, name, bases, dct)
|
|
49
|
-
if not name.startswith('_'):
|
|
50
|
-
if cls.python_type:
|
|
51
|
-
_serializers[cls.python_type] = cls
|
|
52
|
-
if cls.graphson_type:
|
|
53
|
-
_deserializers[cls.graphson_type] = cls
|
|
54
|
-
return cls
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class GraphSONUtil(object):
|
|
58
|
-
TYPE_KEY = "@type"
|
|
59
|
-
VALUE_KEY = "@value"
|
|
60
|
-
|
|
61
|
-
@classmethod
|
|
62
|
-
def typed_value(cls, type_name, value, prefix="g"):
|
|
63
|
-
out = {cls.TYPE_KEY: cls.format_type(prefix, type_name)}
|
|
64
|
-
if value is not None:
|
|
65
|
-
out[cls.VALUE_KEY] = value
|
|
66
|
-
return out
|
|
67
|
-
|
|
68
|
-
@classmethod
|
|
69
|
-
def format_type(cls, prefix, type_name):
|
|
70
|
-
return "%s:%s" % (prefix, type_name)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# Read/Write classes split to follow precedence of the Java API
|
|
74
|
-
class GraphSONWriter(object):
|
|
75
|
-
def __init__(self, serializer_map=None):
|
|
76
|
-
"""
|
|
77
|
-
:param serializer_map: map from Python type to serializer instance implementing `dictify`
|
|
78
|
-
"""
|
|
79
|
-
self.serializers = _serializers.copy()
|
|
80
|
-
if serializer_map:
|
|
81
|
-
self.serializers.update(serializer_map)
|
|
82
|
-
|
|
83
|
-
def write_object(self, objectData):
|
|
84
|
-
# to JSON
|
|
85
|
-
return json.dumps(self.to_dict(objectData), separators=(',', ':'))
|
|
86
|
-
|
|
87
|
-
def to_dict(self, obj):
|
|
88
|
-
"""
|
|
89
|
-
Encodes python objects in GraphSON type-tagged dict values
|
|
90
|
-
"""
|
|
91
|
-
try:
|
|
92
|
-
return self.serializers[type(obj)].dictify(obj, self)
|
|
93
|
-
except KeyError:
|
|
94
|
-
for key, serializer in self.serializers.items():
|
|
95
|
-
if isinstance(obj, key):
|
|
96
|
-
return serializer.dictify(obj, self)
|
|
97
|
-
|
|
98
|
-
if isinstance(obj, dict):
|
|
99
|
-
return dict((self.to_dict(k), self.to_dict(v)) for k, v in obj.items())
|
|
100
|
-
elif isinstance(obj, set):
|
|
101
|
-
return set([self.to_dict(o) for o in obj])
|
|
102
|
-
elif isinstance(obj, list):
|
|
103
|
-
return [self.to_dict(o) for o in obj]
|
|
104
|
-
else:
|
|
105
|
-
return obj
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
class GraphSONReader(object):
|
|
109
|
-
def __init__(self, deserializer_map=None):
|
|
110
|
-
"""
|
|
111
|
-
:param deserializer_map: map from GraphSON type tag to deserializer instance implementing `objectify`
|
|
112
|
-
"""
|
|
113
|
-
self.deserializers = _deserializers.copy()
|
|
114
|
-
if deserializer_map:
|
|
115
|
-
self.deserializers.update(deserializer_map)
|
|
116
|
-
|
|
117
|
-
def read_object(self, json_data):
|
|
118
|
-
# from JSON
|
|
119
|
-
return self.to_object(json.loads(json_data))
|
|
120
|
-
|
|
121
|
-
def to_object(self, obj):
|
|
122
|
-
"""
|
|
123
|
-
Unpacks GraphSON type-tagged dict values into objects mapped in self.deserializers
|
|
124
|
-
"""
|
|
125
|
-
if isinstance(obj, dict):
|
|
126
|
-
try:
|
|
127
|
-
return self.deserializers[obj[GraphSONUtil.TYPE_KEY]].objectify(obj[GraphSONUtil.VALUE_KEY], self)
|
|
128
|
-
except KeyError:
|
|
129
|
-
pass
|
|
130
|
-
return dict((self.to_object(k), self.to_object(v)) for k, v in obj.items())
|
|
131
|
-
elif isinstance(obj, set):
|
|
132
|
-
return set([self.to_object(o) for o in obj])
|
|
133
|
-
elif isinstance(obj, list):
|
|
134
|
-
return [self.to_object(o) for o in obj]
|
|
135
|
-
else:
|
|
136
|
-
return obj
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class _GraphSONTypeIO(object, metaclass=GraphSONTypeType):
|
|
140
|
-
python_type = None
|
|
141
|
-
graphson_type = None
|
|
142
|
-
|
|
143
|
-
def dictify(self, obj, writer):
|
|
144
|
-
raise NotImplementedError()
|
|
145
|
-
|
|
146
|
-
def objectify(self, d, reader):
|
|
147
|
-
raise NotImplementedError()
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class VertexSerializer(_GraphSONTypeIO):
|
|
151
|
-
python_type = Vertex
|
|
152
|
-
graphson_type = "g:Vertex"
|
|
153
|
-
|
|
154
|
-
@classmethod
|
|
155
|
-
def dictify(cls, vertex, writer):
|
|
156
|
-
return GraphSONUtil.typed_value("Vertex", {"id": writer.to_dict(vertex.id),
|
|
157
|
-
"label": [writer.to_dict(vertex.label)]})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class EdgeSerializer(_GraphSONTypeIO):
|
|
161
|
-
python_type = Edge
|
|
162
|
-
graphson_type = "g:Edge"
|
|
163
|
-
|
|
164
|
-
@classmethod
|
|
165
|
-
def dictify(cls, edge, writer):
|
|
166
|
-
return GraphSONUtil.typed_value("Edge", {"id": writer.to_dict(edge.id),
|
|
167
|
-
"label": [writer.to_dict(edge.label)],
|
|
168
|
-
"inV": {
|
|
169
|
-
"id": writer.to_dict(edge.inV.id),
|
|
170
|
-
"label": [writer.to_dict(edge.inV.label)]
|
|
171
|
-
},
|
|
172
|
-
"outV": {
|
|
173
|
-
"id": writer.to_dict(edge.outV.id),
|
|
174
|
-
"label": [writer.to_dict(edge.outV.label)]
|
|
175
|
-
}})
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
class VertexPropertySerializer(_GraphSONTypeIO):
|
|
179
|
-
python_type = VertexProperty
|
|
180
|
-
graphson_type = "g:VertexProperty"
|
|
181
|
-
|
|
182
|
-
@classmethod
|
|
183
|
-
def dictify(cls, vertex_property, writer):
|
|
184
|
-
return GraphSONUtil.typed_value("VertexProperty", {"id": writer.to_dict(vertex_property.id),
|
|
185
|
-
"label": [writer.to_dict(vertex_property.label)],
|
|
186
|
-
"value": writer.to_dict(vertex_property.value)})
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
class PropertySerializer(_GraphSONTypeIO):
|
|
190
|
-
python_type = Property
|
|
191
|
-
graphson_type = "g:Property"
|
|
192
|
-
|
|
193
|
-
@classmethod
|
|
194
|
-
def dictify(cls, property, writer):
|
|
195
|
-
return GraphSONUtil.typed_value("Property", {"key": writer.to_dict(property.key),
|
|
196
|
-
"value": writer.to_dict(property.value)})
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
class UUIDIO(_GraphSONTypeIO):
|
|
200
|
-
python_type = uuid.UUID
|
|
201
|
-
graphson_type = "g:UUID"
|
|
202
|
-
graphson_base_type = "UUID"
|
|
203
|
-
|
|
204
|
-
@classmethod
|
|
205
|
-
def dictify(cls, obj, writer):
|
|
206
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, str(obj))
|
|
207
|
-
|
|
208
|
-
@classmethod
|
|
209
|
-
def objectify(cls, d, reader):
|
|
210
|
-
return cls.python_type(d)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
class DateTimeIO(_GraphSONTypeIO):
|
|
214
|
-
python_type = datetime.datetime
|
|
215
|
-
graphson_type = "g:DateTime"
|
|
216
|
-
graphson_base_type = "DateTime"
|
|
217
|
-
|
|
218
|
-
@classmethod
|
|
219
|
-
def dictify(cls, obj, writer):
|
|
220
|
-
if obj.tzinfo is None:
|
|
221
|
-
raise AttributeError("Timezone information is required when constructing datetime")
|
|
222
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, obj.isoformat())
|
|
223
|
-
|
|
224
|
-
@classmethod
|
|
225
|
-
def objectify(cls, dt, reader):
|
|
226
|
-
# specially handling as python isoformat does not support zulu until 3.11
|
|
227
|
-
dt_iso = dt[:-1] + '+00:00' if dt.endswith('Z') else dt
|
|
228
|
-
return datetime.datetime.fromisoformat(dt_iso)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
class _NumberIO(_GraphSONTypeIO):
|
|
232
|
-
@classmethod
|
|
233
|
-
def dictify(cls, n, writer):
|
|
234
|
-
if isinstance(n, bool): # because isinstance(False, int) and isinstance(True, int)
|
|
235
|
-
return n
|
|
236
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n)
|
|
237
|
-
|
|
238
|
-
@classmethod
|
|
239
|
-
def objectify(cls, v, _):
|
|
240
|
-
return cls.python_type(v)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
class ListIO(_GraphSONTypeIO):
|
|
244
|
-
python_type = ListType
|
|
245
|
-
graphson_type = "g:List"
|
|
246
|
-
|
|
247
|
-
@classmethod
|
|
248
|
-
def dictify(cls, l, writer):
|
|
249
|
-
new_list = []
|
|
250
|
-
for obj in l:
|
|
251
|
-
new_list.append(writer.to_dict(obj))
|
|
252
|
-
return GraphSONUtil.typed_value("List", new_list)
|
|
253
|
-
|
|
254
|
-
@classmethod
|
|
255
|
-
def objectify(cls, l, reader):
|
|
256
|
-
new_list = []
|
|
257
|
-
for obj in l:
|
|
258
|
-
new_list.append(reader.to_object(obj))
|
|
259
|
-
return new_list
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
class SetIO(_GraphSONTypeIO):
|
|
263
|
-
python_type = SetType
|
|
264
|
-
graphson_type = "g:Set"
|
|
265
|
-
|
|
266
|
-
@classmethod
|
|
267
|
-
def dictify(cls, s, writer):
|
|
268
|
-
new_list = []
|
|
269
|
-
for obj in s:
|
|
270
|
-
new_list.append(writer.to_dict(obj))
|
|
271
|
-
return GraphSONUtil.typed_value("Set", new_list)
|
|
272
|
-
|
|
273
|
-
@classmethod
|
|
274
|
-
def objectify(cls, s, reader):
|
|
275
|
-
"""
|
|
276
|
-
By default, returns a python set
|
|
277
|
-
|
|
278
|
-
In case Java returns numeric values of different types which
|
|
279
|
-
python don't recognize, coerce and return a list.
|
|
280
|
-
See comments of TINKERPOP-1844 for more details
|
|
281
|
-
|
|
282
|
-
In case the set contains non-hashable elements (e.g. dict, list),
|
|
283
|
-
coerce and return a list.
|
|
284
|
-
See TINKERPOP-3232 for more details
|
|
285
|
-
"""
|
|
286
|
-
new_list = [reader.to_object(obj) for obj in s]
|
|
287
|
-
try:
|
|
288
|
-
new_set = set(new_list)
|
|
289
|
-
except TypeError:
|
|
290
|
-
log.warning("Coercing g:Set to list as it contains unhashable elements (e.g. dict, list). "
|
|
291
|
-
"See TINKERPOP-3232 for more details.")
|
|
292
|
-
return new_list
|
|
293
|
-
if len(new_list) != len(new_set):
|
|
294
|
-
log.warning("Coercing g:Set to list due to java numeric values. "
|
|
295
|
-
"See TINKERPOP-1844 for more details.")
|
|
296
|
-
return new_list
|
|
297
|
-
|
|
298
|
-
return new_set
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
class MapType(_GraphSONTypeIO):
|
|
302
|
-
python_type = DictType
|
|
303
|
-
graphson_type = "g:Map"
|
|
304
|
-
|
|
305
|
-
@classmethod
|
|
306
|
-
def dictify(cls, d, writer):
|
|
307
|
-
l = []
|
|
308
|
-
for key in d:
|
|
309
|
-
l.append(writer.to_dict(key))
|
|
310
|
-
l.append(writer.to_dict(d[key]))
|
|
311
|
-
return GraphSONUtil.typed_value("Map", l)
|
|
312
|
-
|
|
313
|
-
@classmethod
|
|
314
|
-
def objectify(cls, l, reader):
|
|
315
|
-
new_dict = {}
|
|
316
|
-
if len(l) > 0:
|
|
317
|
-
x = 0
|
|
318
|
-
while x < len(l):
|
|
319
|
-
new_dict[HashableDict.of(reader.to_object(l[x]))] = reader.to_object(l[x + 1])
|
|
320
|
-
x = x + 2
|
|
321
|
-
return new_dict
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
class FloatIO(_NumberIO):
|
|
325
|
-
python_type = FloatType
|
|
326
|
-
graphson_type = "g:Float"
|
|
327
|
-
graphson_base_type = "Float"
|
|
328
|
-
|
|
329
|
-
@classmethod
|
|
330
|
-
def dictify(cls, n, writer):
|
|
331
|
-
if isinstance(n, bool): # because isinstance(False, int) and isinstance(True, int)
|
|
332
|
-
return n
|
|
333
|
-
elif math.isnan(n):
|
|
334
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "NaN")
|
|
335
|
-
elif math.isinf(n) and n > 0:
|
|
336
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "Infinity")
|
|
337
|
-
elif math.isinf(n) and n < 0:
|
|
338
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "-Infinity")
|
|
339
|
-
else:
|
|
340
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n)
|
|
341
|
-
|
|
342
|
-
@classmethod
|
|
343
|
-
def objectify(cls, v, _):
|
|
344
|
-
if isinstance(v, str):
|
|
345
|
-
if v == 'NaN':
|
|
346
|
-
return float('nan')
|
|
347
|
-
elif v == "Infinity":
|
|
348
|
-
return float('inf')
|
|
349
|
-
elif v == "-Infinity":
|
|
350
|
-
return float('-inf')
|
|
351
|
-
|
|
352
|
-
return cls.python_type(v)
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
class BigDecimalIO(_GraphSONTypeIO):
|
|
356
|
-
python_type = BigDecimal
|
|
357
|
-
graphson_type = "g:BigDecimal"
|
|
358
|
-
graphson_base_type = "BigDecimal"
|
|
359
|
-
|
|
360
|
-
@classmethod
|
|
361
|
-
def dictify(cls, n, writer):
|
|
362
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, str(n.value), "g")
|
|
363
|
-
|
|
364
|
-
@classmethod
|
|
365
|
-
def objectify(cls, v, _):
|
|
366
|
-
return bigdecimal(v)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
class DoubleIO(FloatIO):
|
|
370
|
-
graphson_type = "g:Double"
|
|
371
|
-
graphson_base_type = "Double"
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
class Int64IO(_NumberIO):
|
|
375
|
-
python_type = LongType
|
|
376
|
-
graphson_type = "g:Int64"
|
|
377
|
-
graphson_base_type = "Int64"
|
|
378
|
-
|
|
379
|
-
@classmethod
|
|
380
|
-
def dictify(cls, n, writer):
|
|
381
|
-
# if we exceed Java long range then we need a BigInteger
|
|
382
|
-
if isinstance(n, bool):
|
|
383
|
-
return n
|
|
384
|
-
elif n < -9223372036854775808 or n > 9223372036854775807:
|
|
385
|
-
return GraphSONUtil.typed_value("BigInteger", str(n), "g")
|
|
386
|
-
else:
|
|
387
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
class BigIntegerIO(Int64IO):
|
|
391
|
-
graphson_type = "g:BigInteger"
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
class Int32IO(Int64IO):
|
|
395
|
-
python_type = IntType
|
|
396
|
-
graphson_type = "g:Int32"
|
|
397
|
-
graphson_base_type = "Int32"
|
|
398
|
-
|
|
399
|
-
@classmethod
|
|
400
|
-
def dictify(cls, n, writer):
|
|
401
|
-
# if we exceed Java int range then we need a long
|
|
402
|
-
if isinstance(n, bool):
|
|
403
|
-
return n
|
|
404
|
-
elif n < -9223372036854775808 or n > 9223372036854775807:
|
|
405
|
-
return GraphSONUtil.typed_value("BigInteger", str(n), "g")
|
|
406
|
-
elif n < -2147483648 or n > 2147483647:
|
|
407
|
-
return GraphSONUtil.typed_value("Int64", n)
|
|
408
|
-
else:
|
|
409
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
class Int16IO(Int64IO):
|
|
413
|
-
python_type = ShortType
|
|
414
|
-
graphson_type = "g:Int16"
|
|
415
|
-
graphson_base_type = "Int16"
|
|
416
|
-
|
|
417
|
-
@classmethod
|
|
418
|
-
def dictify(cls, n, writer):
|
|
419
|
-
# if we exceed Java int range then we need a long
|
|
420
|
-
if isinstance(n, bool):
|
|
421
|
-
return n
|
|
422
|
-
elif n < -9223372036854775808 or n > 9223372036854775807:
|
|
423
|
-
return GraphSONUtil.typed_value("BigInteger", str(n), "g")
|
|
424
|
-
elif n < -2147483648 or n > 2147483647:
|
|
425
|
-
return GraphSONUtil.typed_value("Int64", n)
|
|
426
|
-
elif n < -32768 or n > 32767:
|
|
427
|
-
return GraphSONUtil.typed_value("Int32", n)
|
|
428
|
-
else:
|
|
429
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n, "g")
|
|
430
|
-
|
|
431
|
-
@classmethod
|
|
432
|
-
def objectify(cls, v, _):
|
|
433
|
-
return int.__new__(ShortType, v)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
class ByteIO(_NumberIO):
|
|
437
|
-
python_type = SingleByte
|
|
438
|
-
graphson_type = "g:Byte"
|
|
439
|
-
graphson_base_type = "Byte"
|
|
440
|
-
|
|
441
|
-
@classmethod
|
|
442
|
-
def dictify(cls, n, writer):
|
|
443
|
-
if isinstance(n, bool): # because isinstance(False, int) and isinstance(True, int)
|
|
444
|
-
return n
|
|
445
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n, "g")
|
|
446
|
-
|
|
447
|
-
@classmethod
|
|
448
|
-
def objectify(cls, v, _):
|
|
449
|
-
return int.__new__(SingleByte, v)
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
class BinaryIO(_GraphSONTypeIO):
|
|
453
|
-
python_type = bytes
|
|
454
|
-
graphson_type = "g:Binary"
|
|
455
|
-
graphson_base_type = "Binary"
|
|
456
|
-
|
|
457
|
-
@classmethod
|
|
458
|
-
def dictify(cls, n, writer):
|
|
459
|
-
# writes a JSON String containing base64-encoded bytes
|
|
460
|
-
n_encoded = "".join(chr(x) for x in base64.b64encode(n))
|
|
461
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n_encoded, "g")
|
|
462
|
-
|
|
463
|
-
@classmethod
|
|
464
|
-
def objectify(cls, v, _):
|
|
465
|
-
return base64.b64decode(v)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
class CharIO(_GraphSONTypeIO):
|
|
469
|
-
python_type = SingleChar
|
|
470
|
-
graphson_type = "g:Char"
|
|
471
|
-
graphson_base_type = "Char"
|
|
472
|
-
|
|
473
|
-
@classmethod
|
|
474
|
-
def dictify(cls, n, writer):
|
|
475
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n, "g")
|
|
476
|
-
|
|
477
|
-
@classmethod
|
|
478
|
-
def objectify(cls, v, _):
|
|
479
|
-
return str.__new__(SingleChar, v)
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
class DurationIO(_GraphSONTypeIO):
|
|
483
|
-
python_type = timedelta
|
|
484
|
-
graphson_type = "g:Duration"
|
|
485
|
-
graphson_base_type = "Duration"
|
|
486
|
-
|
|
487
|
-
@classmethod
|
|
488
|
-
def dictify(cls, n, writer):
|
|
489
|
-
n_iso = duration_isoformat(n)
|
|
490
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, n_iso[:-2] + 'T0S' if n_iso.endswith('0D') else n_iso, "g")
|
|
491
|
-
|
|
492
|
-
@classmethod
|
|
493
|
-
def objectify(cls, v, _):
|
|
494
|
-
return parse_duration(v)
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
class VertexDeserializer(_GraphSONTypeIO):
|
|
498
|
-
graphson_type = "g:Vertex"
|
|
499
|
-
|
|
500
|
-
@classmethod
|
|
501
|
-
def objectify(cls, d, reader):
|
|
502
|
-
properties = []
|
|
503
|
-
if "properties" in d:
|
|
504
|
-
properties = reader.to_object(d["properties"])
|
|
505
|
-
if properties is not None:
|
|
506
|
-
properties = [item for sublist in properties.values() for item in sublist]
|
|
507
|
-
label = d.get("label", "vertex")
|
|
508
|
-
return Vertex(reader.to_object(d["id"]), label if isinstance(label, str) else label[0], properties)
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
class EdgeDeserializer(_GraphSONTypeIO):
|
|
512
|
-
graphson_type = "g:Edge"
|
|
513
|
-
|
|
514
|
-
@classmethod
|
|
515
|
-
def objectify(cls, d, reader):
|
|
516
|
-
properties = []
|
|
517
|
-
if "properties" in d:
|
|
518
|
-
properties = reader.to_object(d["properties"])
|
|
519
|
-
if properties is not None:
|
|
520
|
-
properties = [item for sublist in properties.values() for item in sublist]
|
|
521
|
-
|
|
522
|
-
print(reader.to_object(d["outV"]))
|
|
523
|
-
|
|
524
|
-
return Edge(reader.to_object(d["id"]),
|
|
525
|
-
Vertex(reader.to_object(d["outV"]).get("id"), reader.to_object(d["outV"]).get("label")[0]),
|
|
526
|
-
d.get("label", "edge")[0],
|
|
527
|
-
Vertex(reader.to_object(d["inV"]).get("id"), reader.to_object(d["outV"]).get("label")[0]),
|
|
528
|
-
properties)
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
class VertexPropertyDeserializer(_GraphSONTypeIO):
|
|
532
|
-
graphson_type = "g:VertexProperty"
|
|
533
|
-
|
|
534
|
-
@classmethod
|
|
535
|
-
def objectify(cls, d, reader):
|
|
536
|
-
properties = []
|
|
537
|
-
if "properties" in d:
|
|
538
|
-
properties = reader.to_object(d["properties"])
|
|
539
|
-
if properties is not None:
|
|
540
|
-
properties = list(map(lambda x: Property(x[0], x[1], None), properties.items()))
|
|
541
|
-
vertex = Vertex(reader.to_object(d.get("vertex"))) if "vertex" in d else None
|
|
542
|
-
return VertexProperty(reader.to_object(d["id"]),
|
|
543
|
-
d["label"][0],
|
|
544
|
-
reader.to_object(d["value"]),
|
|
545
|
-
vertex,
|
|
546
|
-
properties)
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
class PropertyDeserializer(_GraphSONTypeIO):
|
|
550
|
-
graphson_type = "g:Property"
|
|
551
|
-
|
|
552
|
-
@classmethod
|
|
553
|
-
def objectify(cls, d, reader):
|
|
554
|
-
element = reader.to_object(d["element"]) if "element" in d else None
|
|
555
|
-
return Property(d["key"], reader.to_object(d["value"]), element)
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
class PathDeserializer(_GraphSONTypeIO):
|
|
559
|
-
graphson_type = "g:Path"
|
|
560
|
-
|
|
561
|
-
@classmethod
|
|
562
|
-
def objectify(cls, d, reader):
|
|
563
|
-
return Path(reader.to_object(d["labels"]), reader.to_object(d["objects"]))
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
class TIO(_GraphSONTypeIO):
|
|
567
|
-
graphson_type = "g:T"
|
|
568
|
-
graphson_base_type = "T"
|
|
569
|
-
python_type = T
|
|
570
|
-
|
|
571
|
-
@classmethod
|
|
572
|
-
def dictify(cls, t, writer):
|
|
573
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, t.name, "g")
|
|
574
|
-
@classmethod
|
|
575
|
-
def objectify(cls, d, reader):
|
|
576
|
-
return T[d]
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
class DirectionIO(_GraphSONTypeIO):
|
|
580
|
-
graphson_type = "g:Direction"
|
|
581
|
-
graphson_base_type = "Direction"
|
|
582
|
-
python_type = Direction
|
|
583
|
-
|
|
584
|
-
@classmethod
|
|
585
|
-
def dictify(cls, d, writer):
|
|
586
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, d.name, "g")
|
|
587
|
-
|
|
588
|
-
@classmethod
|
|
589
|
-
def objectify(cls, d, reader):
|
|
590
|
-
return Direction[d]
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
class EnumSerializer(_GraphSONTypeIO):
|
|
594
|
-
python_type = Enum
|
|
595
|
-
|
|
596
|
-
@classmethod
|
|
597
|
-
def dictify(cls, enum, _):
|
|
598
|
-
return GraphSONUtil.typed_value(SymbolUtil.to_camel_case(type(enum).__name__),
|
|
599
|
-
SymbolUtil.to_camel_case(str(enum.name)))
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
gremlin_python/__init__.py,sha256=indW-LHWKcXV4LwuBLE3f4O5EkfSk_K_NcsRxR_kxJQ,876
|
|
2
|
-
gremlin_python/statics.py,sha256=V8YHxJrE7M7JtgOSICMUbsOCu7bHk4n63fdFbbf8M1Q,4110
|
|
3
|
-
gremlin_python/driver/__init__.py,sha256=g6RXUex0JTxx26nFwkID-1pxZN8qw-08ddWjeHrLd0Y,852
|
|
4
|
-
gremlin_python/driver/auth.py,sha256=Xn91b_D4LW6TIzgvHvshryEz5GAqA5OPDmBq4kW29GQ,1933
|
|
5
|
-
gremlin_python/driver/client.py,sha256=l69loYFi4B_Wi7QUXCxTagK2ywZehgmRHachKqKbYOM,7259
|
|
6
|
-
gremlin_python/driver/connection.py,sha256=vjEEIffCkqJgsRIrJ-53KP3D5mnOiCBrbkcqpWY5a-M,4105
|
|
7
|
-
gremlin_python/driver/driver_remote_connection.py,sha256=Vnbzy0LiOwt1B8kv4d3xr4dlaaDzAnR3OMrEf2-pnfQ,6090
|
|
8
|
-
gremlin_python/driver/protocol.py,sha256=skxw2i0Pk98B1Hw-SZ8Ec16_BiHb-vCInGpxlvdJppI,7570
|
|
9
|
-
gremlin_python/driver/remote_connection.py,sha256=Q8iNH0Mp7y-yl_RdeQbpMZa3Q5Lbf3f8CmrAI_JdSVQ,2879
|
|
10
|
-
gremlin_python/driver/request.py,sha256=2wVjsr_JHUzupuDqdl7-KntQuz3Es-Sx5c5fvXDQ8Tg,1109
|
|
11
|
-
gremlin_python/driver/resultset.py,sha256=ZskmBY5VRQavwyr4TpV_yatbrl6fCfg3HHXur2bUxlQ,2317
|
|
12
|
-
gremlin_python/driver/serializer.py,sha256=LREXk_lu6mdz6LishHlQOnT7TQLUxU89Mn0C8uwPlAM,7513
|
|
13
|
-
gremlin_python/driver/transport.py,sha256=EMQEbMl4rQrrC5uja4hWfnjtu8nPUBcCMtNHQTXu3Z4,1246
|
|
14
|
-
gremlin_python/driver/useragent.py,sha256=eg2PR37jOhnkdgjK4_OXr9l2cvo8JBqKosrRvJ9Kbjo,1597
|
|
15
|
-
gremlin_python/driver/aiohttp/__init__.py,sha256=Mnk4pWa5nTIrU_VYGdGJYftxPjA9MRZjFVYtvbDjH18,789
|
|
16
|
-
gremlin_python/driver/aiohttp/transport.py,sha256=yBJflyEH-Ud5fREKWmW33sG7oZ0LeWPfIttbkY9i_VQ,9088
|
|
17
|
-
gremlin_python/process/__init__.py,sha256=g6RXUex0JTxx26nFwkID-1pxZN8qw-08ddWjeHrLd0Y,852
|
|
18
|
-
gremlin_python/process/anonymous_traversal.py,sha256=VKJGNXxJ7nE8NShZLE3Cq7u35yB6KLwfatQSxnaNRVQ,2344
|
|
19
|
-
gremlin_python/process/graph_traversal.py,sha256=OG46a6ft5cOX82oMTdx4K1-MizD4koddtcnBq2Tw-0Q,72762
|
|
20
|
-
gremlin_python/process/strategies.py,sha256=lw7csIHrOUajzlEN_6YDRcIW27xXZ0kxw7SghHJJd28,10837
|
|
21
|
-
gremlin_python/process/traversal.py,sha256=OKdD_f54Yeit7ZsMbUvALPovL4e-CktR9iHojopUuBA,32542
|
|
22
|
-
gremlin_python/structure/__init__.py,sha256=g6RXUex0JTxx26nFwkID-1pxZN8qw-08ddWjeHrLd0Y,852
|
|
23
|
-
gremlin_python/structure/graph.py,sha256=djyjonCFR64e0b_aqw8FEd-mdHS7fqunEbemiA6Rd4c,4458
|
|
24
|
-
gremlin_python/structure/io/__init__.py,sha256=g6RXUex0JTxx26nFwkID-1pxZN8qw-08ddWjeHrLd0Y,852
|
|
25
|
-
gremlin_python/structure/io/graphbinaryV4.py,sha256=1CskXKTxAu3A0ABoKyGyZaJg8FJR3AuXC2_0uRpDIlU,30965
|
|
26
|
-
gremlin_python/structure/io/graphsonV4.py,sha256=C0GXWn9OiInKyrowMlcMW4FfcNeRoWVLYitpPv7LBvY,19523
|
|
27
|
-
gremlin_python/structure/io/util.py,sha256=ysIZze-kLzR-DH-o-yJHk-bOulD0gjpUOuC2_OyBEdo,2801
|
|
28
|
-
gremlinpython-4.0.0b2.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
29
|
-
gremlinpython-4.0.0b2.dist-info/licenses/NOTICE,sha256=FMjmoj_l2-AVGy2DCS85d0V5rk2A9R9ODI1qiWMJ0-Q,170
|
|
30
|
-
gremlinpython-4.0.0b2.dist-info/METADATA,sha256=dB1JwwslXd944hlnUkdnycp36THRgenEgegEa3v2zeM,6811
|
|
31
|
-
gremlinpython-4.0.0b2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
32
|
-
gremlinpython-4.0.0b2.dist-info/top_level.txt,sha256=VVeR1g-oOCZBmKIaVzZ7fF2BYrnqOWpw7C2H71ksTAU,15
|
|
33
|
-
gremlinpython-4.0.0b2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|