gremlinpython 3.6.8__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 +20 -0
- gremlin_python/__version__.py +20 -0
- gremlin_python/driver/__init__.py +20 -0
- gremlin_python/driver/aiohttp/__init__.py +18 -0
- gremlin_python/driver/aiohttp/transport.py +242 -0
- gremlin_python/driver/client.py +206 -0
- gremlin_python/driver/connection.py +106 -0
- gremlin_python/driver/driver_remote_connection.py +183 -0
- gremlin_python/driver/protocol.py +259 -0
- gremlin_python/driver/remote_connection.py +84 -0
- gremlin_python/driver/request.py +25 -0
- gremlin_python/driver/resultset.py +100 -0
- gremlin_python/driver/serializer.py +294 -0
- gremlin_python/driver/transport.py +45 -0
- gremlin_python/driver/useragent.py +37 -0
- gremlin_python/process/__init__.py +20 -0
- gremlin_python/process/anonymous_traversal.py +64 -0
- gremlin_python/process/graph_traversal.py +2301 -0
- gremlin_python/process/strategies.py +239 -0
- gremlin_python/process/translator.py +297 -0
- gremlin_python/process/traversal.py +875 -0
- gremlin_python/statics.py +117 -0
- gremlin_python/structure/__init__.py +20 -0
- gremlin_python/structure/graph.py +134 -0
- gremlin_python/structure/io/__init__.py +20 -0
- gremlin_python/structure/io/graphbinaryV1.py +1153 -0
- gremlin_python/structure/io/graphsonV2d0.py +646 -0
- gremlin_python/structure/io/graphsonV3d0.py +766 -0
- gremlin_python/structure/io/util.py +60 -0
- gremlinpython-3.6.8.data/data/LICENSE +202 -0
- gremlinpython-3.6.8.data/data/NOTICE +5 -0
- gremlinpython-3.6.8.dist-info/LICENSE +202 -0
- gremlinpython-3.6.8.dist-info/METADATA +147 -0
- gremlinpython-3.6.8.dist-info/NOTICE +5 -0
- gremlinpython-3.6.8.dist-info/RECORD +37 -0
- gremlinpython-3.6.8.dist-info/WHEEL +5 -0
- gremlinpython-3.6.8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
import copy
|
|
21
|
+
import warnings
|
|
22
|
+
from aenum import Enum
|
|
23
|
+
from .. import statics
|
|
24
|
+
from ..statics import long
|
|
25
|
+
|
|
26
|
+
class Traversal(object):
|
|
27
|
+
def __init__(self, graph, traversal_strategies, bytecode):
|
|
28
|
+
self.graph = graph
|
|
29
|
+
self.traversal_strategies = traversal_strategies
|
|
30
|
+
self.bytecode = bytecode
|
|
31
|
+
self.traversers = None
|
|
32
|
+
self.last_traverser = None
|
|
33
|
+
|
|
34
|
+
def __repr__(self):
|
|
35
|
+
return str(self.bytecode)
|
|
36
|
+
|
|
37
|
+
def __eq__(self, other):
|
|
38
|
+
if isinstance(other, self.__class__):
|
|
39
|
+
return self.bytecode == other.bytecode
|
|
40
|
+
else:
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
def __iter__(self):
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def __next__(self):
|
|
47
|
+
if self.traversers is None:
|
|
48
|
+
self.traversal_strategies.apply_strategies(self)
|
|
49
|
+
if self.last_traverser is None:
|
|
50
|
+
self.last_traverser = next(self.traversers)
|
|
51
|
+
object = self.last_traverser.object
|
|
52
|
+
self.last_traverser.bulk = self.last_traverser.bulk - 1
|
|
53
|
+
if self.last_traverser.bulk <= 0:
|
|
54
|
+
self.last_traverser = None
|
|
55
|
+
return object
|
|
56
|
+
|
|
57
|
+
def toList(self):
|
|
58
|
+
warnings.warn(
|
|
59
|
+
"gremlin_python.process.Traversal.toList will be replaced by "
|
|
60
|
+
"gremlin_python.process.Traversal.to_list.",
|
|
61
|
+
DeprecationWarning)
|
|
62
|
+
return self.to_list()
|
|
63
|
+
|
|
64
|
+
def to_list(self):
|
|
65
|
+
return list(iter(self))
|
|
66
|
+
|
|
67
|
+
def toSet(self):
|
|
68
|
+
warnings.warn(
|
|
69
|
+
"gremlin_python.process.Traversal.toSet will be replaced by "
|
|
70
|
+
"gremlin_python.process.Traversal.to_set.",
|
|
71
|
+
DeprecationWarning)
|
|
72
|
+
return self.to_set()
|
|
73
|
+
|
|
74
|
+
def to_set(self):
|
|
75
|
+
return set(iter(self))
|
|
76
|
+
|
|
77
|
+
def iterate(self):
|
|
78
|
+
self.bytecode.add_step("none")
|
|
79
|
+
while True:
|
|
80
|
+
try: self.next_traverser()
|
|
81
|
+
except StopIteration: return self
|
|
82
|
+
|
|
83
|
+
def nextTraverser(self):
|
|
84
|
+
warnings.warn(
|
|
85
|
+
"gremlin_python.process.Traversal.nextTraverser will be replaced by "
|
|
86
|
+
"gremlin_python.process.Traversal.next_traverser.",
|
|
87
|
+
DeprecationWarning)
|
|
88
|
+
return self.next_traverser()
|
|
89
|
+
|
|
90
|
+
def next_traverser(self):
|
|
91
|
+
if self.traversers is None:
|
|
92
|
+
self.traversal_strategies.apply_strategies(self)
|
|
93
|
+
if self.last_traverser is None:
|
|
94
|
+
return next(self.traversers)
|
|
95
|
+
else:
|
|
96
|
+
temp = self.last_traverser
|
|
97
|
+
self.last_traverser = None
|
|
98
|
+
return temp
|
|
99
|
+
|
|
100
|
+
def hasNext(self):
|
|
101
|
+
warnings.warn(
|
|
102
|
+
"gremlin_python.process.Traversal.hasNext will be replaced by "
|
|
103
|
+
"gremlin_python.process.Traversal.has_next.",
|
|
104
|
+
DeprecationWarning)
|
|
105
|
+
return self.has_next()
|
|
106
|
+
|
|
107
|
+
def has_next(self):
|
|
108
|
+
if self.traversers is None:
|
|
109
|
+
self.traversal_strategies.apply_strategies(self)
|
|
110
|
+
if self.last_traverser is None:
|
|
111
|
+
try: self.last_traverser = next(self.traversers)
|
|
112
|
+
except StopIteration: return False
|
|
113
|
+
return not(self.last_traverser is None) and self.last_traverser.bulk > 0
|
|
114
|
+
|
|
115
|
+
def next(self, amount=None):
|
|
116
|
+
if amount is None:
|
|
117
|
+
return self.__next__()
|
|
118
|
+
else:
|
|
119
|
+
count = 0
|
|
120
|
+
tempList = []
|
|
121
|
+
while count < amount:
|
|
122
|
+
count = count + 1
|
|
123
|
+
try: temp = self.__next__()
|
|
124
|
+
except StopIteration: return tempList
|
|
125
|
+
tempList.append(temp)
|
|
126
|
+
return tempList
|
|
127
|
+
|
|
128
|
+
def promise(self, cb=None):
|
|
129
|
+
self.traversal_strategies.apply_async_strategies(self)
|
|
130
|
+
future_traversal = self.remote_results
|
|
131
|
+
future = type(future_traversal)()
|
|
132
|
+
def process(f):
|
|
133
|
+
try:
|
|
134
|
+
traversal = f.result()
|
|
135
|
+
except Exception as e:
|
|
136
|
+
future.set_exception(e)
|
|
137
|
+
else:
|
|
138
|
+
self.traversers = iter(traversal.traversers)
|
|
139
|
+
if cb:
|
|
140
|
+
try:
|
|
141
|
+
result = cb(self)
|
|
142
|
+
except Exception as e:
|
|
143
|
+
future.set_exception(e)
|
|
144
|
+
else:
|
|
145
|
+
future.set_result(result)
|
|
146
|
+
else:
|
|
147
|
+
future.set_result(self)
|
|
148
|
+
future_traversal.add_done_callback(process)
|
|
149
|
+
return future
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Barrier = Enum('Barrier', ' normSack norm_sack')
|
|
153
|
+
|
|
154
|
+
statics.add_static('normSack', Barrier.normSack)
|
|
155
|
+
statics.add_static('norm_sack', Barrier.norm_sack)
|
|
156
|
+
|
|
157
|
+
Cardinality = Enum('Cardinality', ' list_ set_ single')
|
|
158
|
+
|
|
159
|
+
statics.add_static('single', Cardinality.single)
|
|
160
|
+
statics.add_static('list_', Cardinality.list_)
|
|
161
|
+
statics.add_static('set_', Cardinality.set_)
|
|
162
|
+
|
|
163
|
+
Column = Enum('Column', ' keys values')
|
|
164
|
+
|
|
165
|
+
statics.add_static('keys', Column.keys)
|
|
166
|
+
statics.add_static('values', Column.values)
|
|
167
|
+
|
|
168
|
+
# alias from_ and to
|
|
169
|
+
Direction = Enum(
|
|
170
|
+
value='Direction',
|
|
171
|
+
names=[
|
|
172
|
+
('BOTH', 'BOTH'),
|
|
173
|
+
('IN', 'IN'),
|
|
174
|
+
('OUT', 'OUT'),
|
|
175
|
+
('from_', "OUT"),
|
|
176
|
+
('to', 'IN'),
|
|
177
|
+
],
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
statics.add_static('OUT', Direction.OUT)
|
|
181
|
+
statics.add_static('IN', Direction.IN)
|
|
182
|
+
statics.add_static('BOTH', Direction.BOTH)
|
|
183
|
+
statics.add_static('from_', Direction.OUT)
|
|
184
|
+
statics.add_static('to', Direction.IN)
|
|
185
|
+
|
|
186
|
+
GraphSONVersion = Enum('GraphSONVersion', ' V1_0 V2_0 V3_0')
|
|
187
|
+
|
|
188
|
+
statics.add_static('V1_0', GraphSONVersion.V1_0)
|
|
189
|
+
statics.add_static('V2_0', GraphSONVersion.V2_0)
|
|
190
|
+
statics.add_static('V3_0', GraphSONVersion.V3_0)
|
|
191
|
+
|
|
192
|
+
GryoVersion = Enum('GryoVersion', ' V1_0 V3_0')
|
|
193
|
+
|
|
194
|
+
statics.add_static('V1_0', GryoVersion.V1_0)
|
|
195
|
+
statics.add_static('V3_0', GryoVersion.V3_0)
|
|
196
|
+
|
|
197
|
+
Merge = Enum('Merge', ' on_create on_match out_v in_v')
|
|
198
|
+
|
|
199
|
+
statics.add_static('on_create', Merge.on_create)
|
|
200
|
+
statics.add_static('on_match', Merge.on_match)
|
|
201
|
+
statics.add_static('in_v', Merge.in_v)
|
|
202
|
+
statics.add_static('out_v', Merge.out_v)
|
|
203
|
+
|
|
204
|
+
Order = Enum('Order', ' asc desc shuffle')
|
|
205
|
+
|
|
206
|
+
statics.add_static('shuffle', Order.shuffle)
|
|
207
|
+
statics.add_static('asc', Order.asc)
|
|
208
|
+
statics.add_static('desc', Order.desc)
|
|
209
|
+
|
|
210
|
+
Pick = Enum('Pick', ' any_ none')
|
|
211
|
+
|
|
212
|
+
statics.add_static('any_', Pick.any_)
|
|
213
|
+
statics.add_static('none', Pick.none)
|
|
214
|
+
|
|
215
|
+
Pop = Enum('Pop', ' all_ first last mixed')
|
|
216
|
+
|
|
217
|
+
statics.add_static('first', Pop.first)
|
|
218
|
+
statics.add_static('last', Pop.last)
|
|
219
|
+
statics.add_static('all_', Pop.all_)
|
|
220
|
+
statics.add_static('mixed', Pop.mixed)
|
|
221
|
+
|
|
222
|
+
Scope = Enum('Scope', ' global_ local')
|
|
223
|
+
|
|
224
|
+
statics.add_static('global_', Scope.global_)
|
|
225
|
+
statics.add_static('local', Scope.local)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
T = Enum('T', ' id id_ key label value')
|
|
229
|
+
|
|
230
|
+
statics.add_static('id', T.id)
|
|
231
|
+
statics.add_static('label', T.label)
|
|
232
|
+
statics.add_static('id_', T.id_)
|
|
233
|
+
statics.add_static('key', T.key)
|
|
234
|
+
statics.add_static('value', T.value)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
Operator = Enum('Operator', ' addAll add_all and_ assign div max max_ min min_ minus mult or_ sum_ sumLong sum_long')
|
|
238
|
+
|
|
239
|
+
statics.add_static('sum_', Operator.sum_)
|
|
240
|
+
statics.add_static('minus', Operator.minus)
|
|
241
|
+
statics.add_static('mult', Operator.mult)
|
|
242
|
+
statics.add_static('div', Operator.div)
|
|
243
|
+
statics.add_static('min', Operator.min_)
|
|
244
|
+
statics.add_static('min_', Operator.min_)
|
|
245
|
+
statics.add_static('max_', Operator.max_)
|
|
246
|
+
statics.add_static('assign', Operator.assign)
|
|
247
|
+
statics.add_static('and_', Operator.and_)
|
|
248
|
+
statics.add_static('or_', Operator.or_)
|
|
249
|
+
statics.add_static('addAll', Operator.addAll)
|
|
250
|
+
statics.add_static('add_all', Operator.add_all)
|
|
251
|
+
statics.add_static('sum_long', Operator.sum_long)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class P(object):
|
|
255
|
+
def __init__(self, operator, value, other=None):
|
|
256
|
+
self.operator = operator
|
|
257
|
+
self.value = value
|
|
258
|
+
self.other = other
|
|
259
|
+
|
|
260
|
+
@staticmethod
|
|
261
|
+
def between(*args):
|
|
262
|
+
return P("between", *args)
|
|
263
|
+
|
|
264
|
+
@staticmethod
|
|
265
|
+
def eq(*args):
|
|
266
|
+
return P("eq", *args)
|
|
267
|
+
|
|
268
|
+
@staticmethod
|
|
269
|
+
def gt(*args):
|
|
270
|
+
return P("gt", *args)
|
|
271
|
+
|
|
272
|
+
@staticmethod
|
|
273
|
+
def gte(*args):
|
|
274
|
+
return P("gte", *args)
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
def inside(*args):
|
|
278
|
+
return P("inside", *args)
|
|
279
|
+
|
|
280
|
+
@staticmethod
|
|
281
|
+
def lt(*args):
|
|
282
|
+
return P("lt", *args)
|
|
283
|
+
|
|
284
|
+
@staticmethod
|
|
285
|
+
def lte(*args):
|
|
286
|
+
return P("lte", *args)
|
|
287
|
+
|
|
288
|
+
@staticmethod
|
|
289
|
+
def neq(*args):
|
|
290
|
+
return P("neq", *args)
|
|
291
|
+
|
|
292
|
+
@staticmethod
|
|
293
|
+
def not_(*args):
|
|
294
|
+
return P("not", *args)
|
|
295
|
+
|
|
296
|
+
@staticmethod
|
|
297
|
+
def outside(*args):
|
|
298
|
+
return P("outside", *args)
|
|
299
|
+
|
|
300
|
+
@staticmethod
|
|
301
|
+
def test(*args):
|
|
302
|
+
return P("test", *args)
|
|
303
|
+
|
|
304
|
+
@staticmethod
|
|
305
|
+
def within(*args):
|
|
306
|
+
if len(args) == 1 and type(args[0]) == list:
|
|
307
|
+
return P("within", args[0])
|
|
308
|
+
elif len(args) == 1 and type(args[0]) == set:
|
|
309
|
+
return P("within", list(args[0]))
|
|
310
|
+
else:
|
|
311
|
+
return P("within", list(args))
|
|
312
|
+
|
|
313
|
+
@staticmethod
|
|
314
|
+
def without(*args):
|
|
315
|
+
if len(args) == 1 and type(args[0]) == list:
|
|
316
|
+
return P("without", args[0])
|
|
317
|
+
elif len(args) == 1 and type(args[0]) == set:
|
|
318
|
+
return P("without", list(args[0]))
|
|
319
|
+
else:
|
|
320
|
+
return P("without", list(args))
|
|
321
|
+
|
|
322
|
+
def and_(self, arg):
|
|
323
|
+
return P("and", self, arg)
|
|
324
|
+
|
|
325
|
+
def or_(self, arg):
|
|
326
|
+
return P("or", self, arg)
|
|
327
|
+
|
|
328
|
+
def __eq__(self, other):
|
|
329
|
+
return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other
|
|
330
|
+
|
|
331
|
+
def __repr__(self):
|
|
332
|
+
return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def between(*args):
|
|
336
|
+
return P.between(*args)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def eq(*args):
|
|
340
|
+
return P.eq(*args)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def gt(*args):
|
|
344
|
+
return P.gt(*args)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def gte(*args):
|
|
348
|
+
return P.gte(*args)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def inside(*args):
|
|
352
|
+
return P.inside(*args)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def lt(*args):
|
|
356
|
+
return P.lt(*args)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def lte(*args):
|
|
360
|
+
return P.lte(*args)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def neq(*args):
|
|
364
|
+
return P.neq(*args)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def not_(*args):
|
|
368
|
+
return P.not_(*args)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def outside(*args):
|
|
372
|
+
return P.outside(*args)
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def within(*args):
|
|
376
|
+
return P.within(*args)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def without(*args):
|
|
380
|
+
return P.without(*args)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
statics.add_static('between', between)
|
|
384
|
+
|
|
385
|
+
statics.add_static('eq', eq)
|
|
386
|
+
|
|
387
|
+
statics.add_static('gt', gt)
|
|
388
|
+
|
|
389
|
+
statics.add_static('gte', gte)
|
|
390
|
+
|
|
391
|
+
statics.add_static('inside', inside)
|
|
392
|
+
|
|
393
|
+
statics.add_static('lt', lt)
|
|
394
|
+
|
|
395
|
+
statics.add_static('lte', lte)
|
|
396
|
+
|
|
397
|
+
statics.add_static('neq', neq)
|
|
398
|
+
|
|
399
|
+
statics.add_static('not_', not_)
|
|
400
|
+
|
|
401
|
+
statics.add_static('outside', outside)
|
|
402
|
+
|
|
403
|
+
statics.add_static('within', within)
|
|
404
|
+
|
|
405
|
+
statics.add_static('without', without)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class TextP(P):
|
|
409
|
+
def __init__(self, operator, value, other=None):
|
|
410
|
+
P.__init__(self, operator, value, other)
|
|
411
|
+
|
|
412
|
+
@staticmethod
|
|
413
|
+
def containing(*args):
|
|
414
|
+
return TextP("containing", *args)
|
|
415
|
+
|
|
416
|
+
@staticmethod
|
|
417
|
+
def endingWith(*args):
|
|
418
|
+
warnings.warn(
|
|
419
|
+
"gremlin_python.process.TextP.endingWith will be replaced by "
|
|
420
|
+
"gremlin_python.process.TextP.ending_with.",
|
|
421
|
+
DeprecationWarning)
|
|
422
|
+
return TextP("endingWith", *args)
|
|
423
|
+
|
|
424
|
+
@staticmethod
|
|
425
|
+
def ending_with(*args):
|
|
426
|
+
return TextP("endingWith", *args)
|
|
427
|
+
|
|
428
|
+
@staticmethod
|
|
429
|
+
def notContaining(*args):
|
|
430
|
+
warnings.warn(
|
|
431
|
+
"gremlin_python.process.TextP.notContaining will be replaced by "
|
|
432
|
+
"gremlin_python.process.TextP.not_containing.",
|
|
433
|
+
DeprecationWarning)
|
|
434
|
+
return TextP("notContaining", *args)
|
|
435
|
+
|
|
436
|
+
@staticmethod
|
|
437
|
+
def not_containing(*args):
|
|
438
|
+
return TextP("notContaining", *args)
|
|
439
|
+
|
|
440
|
+
@staticmethod
|
|
441
|
+
def notEndingWith(*args):
|
|
442
|
+
warnings.warn(
|
|
443
|
+
"gremlin_python.process.TextP.notEndingWith will be replaced by "
|
|
444
|
+
"gremlin_python.process.TextP.not_ending_with.",
|
|
445
|
+
DeprecationWarning)
|
|
446
|
+
return TextP("notEndingWith", *args)
|
|
447
|
+
|
|
448
|
+
@staticmethod
|
|
449
|
+
def not_ending_with(*args):
|
|
450
|
+
return TextP("notEndingWith", *args)
|
|
451
|
+
|
|
452
|
+
@staticmethod
|
|
453
|
+
def notStartingWith(*args):
|
|
454
|
+
warnings.warn(
|
|
455
|
+
"gremlin_python.process.TextP.notStartingWith will be replaced by "
|
|
456
|
+
"gremlin_python.process.TextP.not_starting_With.",
|
|
457
|
+
DeprecationWarning)
|
|
458
|
+
return TextP("notStartingWith", *args)
|
|
459
|
+
|
|
460
|
+
@staticmethod
|
|
461
|
+
def not_starting_with(*args):
|
|
462
|
+
return TextP("notStartingWith", *args)
|
|
463
|
+
|
|
464
|
+
@staticmethod
|
|
465
|
+
def startingWith(*args):
|
|
466
|
+
warnings.warn(
|
|
467
|
+
"gremlin_python.process.TextP.startingWith will be replaced by "
|
|
468
|
+
"gremlin_python.process.TextP.startingWith.",
|
|
469
|
+
DeprecationWarning)
|
|
470
|
+
return TextP("startingWith", *args)
|
|
471
|
+
|
|
472
|
+
@staticmethod
|
|
473
|
+
def starting_with(*args):
|
|
474
|
+
return TextP("startingWith", *args)
|
|
475
|
+
|
|
476
|
+
@staticmethod
|
|
477
|
+
def regex(*args):
|
|
478
|
+
return TextP("regex", *args)
|
|
479
|
+
|
|
480
|
+
@staticmethod
|
|
481
|
+
def not_regex(*args):
|
|
482
|
+
return TextP("notRegex", *args)
|
|
483
|
+
|
|
484
|
+
def __eq__(self, other):
|
|
485
|
+
return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other
|
|
486
|
+
|
|
487
|
+
def __repr__(self):
|
|
488
|
+
return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
def containing(*args):
|
|
492
|
+
return TextP.containing(*args)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
def endingWith(*args):
|
|
496
|
+
return TextP.ending_with(*args)
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def ending_with(*args):
|
|
500
|
+
return TextP.ending_with(*args)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def notContaining(*args):
|
|
504
|
+
return TextP.not_containing(*args)
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
def not_containing(*args):
|
|
508
|
+
return TextP.not_containing(*args)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def notEndingWith(*args):
|
|
512
|
+
return TextP.not_ending_with(*args)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def not_ending_with(*args):
|
|
516
|
+
return TextP.not_ending_with(*args)
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
def notStartingWith(*args):
|
|
520
|
+
return TextP.not_starting_with(*args)
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
def not_starting_with(*args):
|
|
524
|
+
return TextP.not_starting_with(*args)
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
def startingWith(*args):
|
|
528
|
+
return TextP.starting_with(*args)
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
def starting_with(*args):
|
|
532
|
+
return TextP.starting_with(*args)
|
|
533
|
+
|
|
534
|
+
def regex(*args):
|
|
535
|
+
return TextP.regex(*args)
|
|
536
|
+
|
|
537
|
+
def not_regex(*args):
|
|
538
|
+
return TextP.not_regex(*args)
|
|
539
|
+
|
|
540
|
+
statics.add_static('containing', containing)
|
|
541
|
+
|
|
542
|
+
statics.add_static('endingWith', endingWith)
|
|
543
|
+
|
|
544
|
+
statics.add_static('ending_with', ending_with)
|
|
545
|
+
|
|
546
|
+
statics.add_static('notContaining', notContaining)
|
|
547
|
+
|
|
548
|
+
statics.add_static('not_containing', not_containing)
|
|
549
|
+
|
|
550
|
+
statics.add_static('notEndingWith', notEndingWith)
|
|
551
|
+
|
|
552
|
+
statics.add_static('not_ending_with', not_ending_with)
|
|
553
|
+
|
|
554
|
+
statics.add_static('notStartingWith', notStartingWith)
|
|
555
|
+
|
|
556
|
+
statics.add_static('not_starting_with', not_starting_with)
|
|
557
|
+
|
|
558
|
+
statics.add_static('startingWith', startingWith)
|
|
559
|
+
|
|
560
|
+
statics.add_static('starting_with', starting_with)
|
|
561
|
+
|
|
562
|
+
statics.add_static('regex', regex)
|
|
563
|
+
|
|
564
|
+
statics.add_static('not_regex', not_regex)
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
'''
|
|
570
|
+
IO
|
|
571
|
+
'''
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
class IO(object):
|
|
575
|
+
|
|
576
|
+
graphml = "graphml"
|
|
577
|
+
|
|
578
|
+
graphson = "graphson"
|
|
579
|
+
|
|
580
|
+
gryo = "gryo"
|
|
581
|
+
|
|
582
|
+
reader = "~tinkerpop.io.reader"
|
|
583
|
+
|
|
584
|
+
registry = "~tinkerpop.io.registry"
|
|
585
|
+
|
|
586
|
+
writer = "~tinkerpop.io.writer"
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
'''
|
|
590
|
+
ConnectedComponent
|
|
591
|
+
'''
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
class ConnectedComponent(object):
|
|
595
|
+
|
|
596
|
+
component = "gremlin.connectedComponentVertexProgram.component"
|
|
597
|
+
|
|
598
|
+
edges = "~tinkerpop.connectedComponent.edges"
|
|
599
|
+
|
|
600
|
+
propertyName = "~tinkerpop.connectedComponent.propertyName"
|
|
601
|
+
|
|
602
|
+
property_name = "~tinkerpop.connectedComponent.propertyName"
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
'''
|
|
606
|
+
ShortestPath
|
|
607
|
+
'''
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
class ShortestPath(object):
|
|
611
|
+
|
|
612
|
+
distance = "~tinkerpop.shortestPath.distance"
|
|
613
|
+
|
|
614
|
+
edges = "~tinkerpop.shortestPath.edges"
|
|
615
|
+
|
|
616
|
+
includeEdges = "~tinkerpop.shortestPath.includeEdges"
|
|
617
|
+
|
|
618
|
+
include_edges = "~tinkerpop.shortestPath.includeEdges"
|
|
619
|
+
|
|
620
|
+
maxDistance = "~tinkerpop.shortestPath.maxDistance"
|
|
621
|
+
|
|
622
|
+
max_distance = "~tinkerpop.shortestPath.maxDistance"
|
|
623
|
+
|
|
624
|
+
target = "~tinkerpop.shortestPath.target"
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
'''
|
|
628
|
+
PageRank
|
|
629
|
+
'''
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
class PageRank(object):
|
|
633
|
+
|
|
634
|
+
edges = "~tinkerpop.pageRank.edges"
|
|
635
|
+
|
|
636
|
+
propertyName = "~tinkerpop.pageRank.propertyName"
|
|
637
|
+
|
|
638
|
+
property_name = "~tinkerpop.pageRank.propertyName"
|
|
639
|
+
|
|
640
|
+
times = "~tinkerpop.pageRank.times"
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
'''
|
|
644
|
+
PeerPressure
|
|
645
|
+
'''
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
class PeerPressure(object):
|
|
649
|
+
|
|
650
|
+
edges = "~tinkerpop.peerPressure.edges"
|
|
651
|
+
|
|
652
|
+
propertyName = "~tinkerpop.peerPressure.propertyName"
|
|
653
|
+
|
|
654
|
+
property_name = "~tinkerpop.pageRank.propertyName"
|
|
655
|
+
|
|
656
|
+
times = "~tinkerpop.peerPressure.times"
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
'''
|
|
660
|
+
TRAVERSER
|
|
661
|
+
'''
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
class Traverser(object):
|
|
665
|
+
def __init__(self, object, bulk=None):
|
|
666
|
+
if bulk is None:
|
|
667
|
+
bulk = long(1)
|
|
668
|
+
self.object = object
|
|
669
|
+
self.bulk = bulk
|
|
670
|
+
|
|
671
|
+
def __repr__(self):
|
|
672
|
+
return str(self.object)
|
|
673
|
+
|
|
674
|
+
def __eq__(self, other):
|
|
675
|
+
return isinstance(other, self.__class__) and self.object == other.object
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
'''
|
|
679
|
+
TRAVERSAL STRATEGIES
|
|
680
|
+
'''
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
class TraversalStrategies(object):
|
|
684
|
+
global_cache = {}
|
|
685
|
+
|
|
686
|
+
def __init__(self, traversal_strategies=None):
|
|
687
|
+
self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies is not None else []
|
|
688
|
+
|
|
689
|
+
def add_strategies(self, traversal_strategies):
|
|
690
|
+
self.traversal_strategies = self.traversal_strategies + traversal_strategies
|
|
691
|
+
|
|
692
|
+
def apply_strategies(self, traversal):
|
|
693
|
+
for traversal_strategy in self.traversal_strategies:
|
|
694
|
+
traversal_strategy.apply(traversal)
|
|
695
|
+
|
|
696
|
+
def apply_async_strategies(self, traversal):
|
|
697
|
+
for traversal_strategy in self.traversal_strategies:
|
|
698
|
+
traversal_strategy.apply_async(traversal)
|
|
699
|
+
|
|
700
|
+
def __repr__(self):
|
|
701
|
+
return str(self.traversal_strategies)
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
class TraversalStrategy(object):
|
|
705
|
+
def __init__(self, strategy_name=None, configuration=None, fqcn=None):
|
|
706
|
+
self.fqcn = fqcn
|
|
707
|
+
self.strategy_name = type(self).__name__ if strategy_name is None else strategy_name
|
|
708
|
+
self.configuration = {} if configuration is None else configuration
|
|
709
|
+
|
|
710
|
+
def apply(self, traversal):
|
|
711
|
+
return
|
|
712
|
+
|
|
713
|
+
def apply_async(self, traversal):
|
|
714
|
+
return
|
|
715
|
+
|
|
716
|
+
def __eq__(self, other):
|
|
717
|
+
return isinstance(other, self.__class__)
|
|
718
|
+
|
|
719
|
+
def __hash__(self):
|
|
720
|
+
return hash(self.strategy_name)
|
|
721
|
+
|
|
722
|
+
def __repr__(self):
|
|
723
|
+
return self.strategy_name
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
'''
|
|
727
|
+
BYTECODE
|
|
728
|
+
'''
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
class Bytecode(object):
|
|
732
|
+
def __init__(self, bytecode=None):
|
|
733
|
+
self.source_instructions = []
|
|
734
|
+
self.step_instructions = []
|
|
735
|
+
self.bindings = {}
|
|
736
|
+
if bytecode is not None:
|
|
737
|
+
self.source_instructions = list(bytecode.source_instructions)
|
|
738
|
+
self.step_instructions = list(bytecode.step_instructions)
|
|
739
|
+
|
|
740
|
+
def add_source(self, source_name, *args):
|
|
741
|
+
instruction = [source_name]
|
|
742
|
+
for arg in args:
|
|
743
|
+
instruction.append(self.__convertArgument(arg))
|
|
744
|
+
self.source_instructions.append(instruction)
|
|
745
|
+
|
|
746
|
+
def add_step(self, step_name, *args):
|
|
747
|
+
instruction = [step_name]
|
|
748
|
+
for arg in args:
|
|
749
|
+
instruction.append(self.__convertArgument(arg))
|
|
750
|
+
self.step_instructions.append(instruction)
|
|
751
|
+
|
|
752
|
+
def __eq__(self, other):
|
|
753
|
+
if isinstance(other, self.__class__):
|
|
754
|
+
return self.source_instructions == other.source_instructions and self.step_instructions == other.step_instructions
|
|
755
|
+
else:
|
|
756
|
+
return False
|
|
757
|
+
|
|
758
|
+
def __copy__(self):
|
|
759
|
+
bb = Bytecode()
|
|
760
|
+
bb.source_instructions = self.source_instructions
|
|
761
|
+
bb.step_instructions = self.step_instructions
|
|
762
|
+
bb.bindings = self.bindings
|
|
763
|
+
return bb
|
|
764
|
+
|
|
765
|
+
def __deepcopy__(self, memo={}):
|
|
766
|
+
bb = Bytecode()
|
|
767
|
+
bb.source_instructions = copy.deepcopy(self.source_instructions, memo)
|
|
768
|
+
bb.step_instructions = copy.deepcopy(self.step_instructions, memo)
|
|
769
|
+
bb.bindings = copy.deepcopy(self.bindings, memo)
|
|
770
|
+
return bb
|
|
771
|
+
|
|
772
|
+
def __convertArgument(self, arg):
|
|
773
|
+
if isinstance(arg, Traversal):
|
|
774
|
+
if arg.graph is not None:
|
|
775
|
+
raise TypeError("The child traversal of " + str(arg) + " was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal")
|
|
776
|
+
self.bindings.update(arg.bytecode.bindings)
|
|
777
|
+
return arg.bytecode
|
|
778
|
+
elif isinstance(arg, dict):
|
|
779
|
+
newDict = {}
|
|
780
|
+
for key in arg:
|
|
781
|
+
newDict[self.__convertArgument(key)] = self.__convertArgument(arg[key])
|
|
782
|
+
return newDict
|
|
783
|
+
elif isinstance(arg, list):
|
|
784
|
+
newList = []
|
|
785
|
+
for item in arg:
|
|
786
|
+
newList.append(self.__convertArgument(item))
|
|
787
|
+
return newList
|
|
788
|
+
elif isinstance(arg, set):
|
|
789
|
+
newSet = set()
|
|
790
|
+
for item in arg:
|
|
791
|
+
newSet.add(self.__convertArgument(item))
|
|
792
|
+
return newSet
|
|
793
|
+
elif isinstance(arg, Binding):
|
|
794
|
+
self.bindings[arg.key] = arg.value
|
|
795
|
+
return Binding(arg.key, self.__convertArgument(arg.value))
|
|
796
|
+
else:
|
|
797
|
+
return arg
|
|
798
|
+
|
|
799
|
+
def __repr__(self):
|
|
800
|
+
return (str(self.source_instructions) if len(self.source_instructions) > 0 else "") + \
|
|
801
|
+
(str(self.step_instructions) if len(self.step_instructions) > 0 else "")
|
|
802
|
+
|
|
803
|
+
@staticmethod
|
|
804
|
+
def _create_graph_op(name, *values):
|
|
805
|
+
bc = Bytecode()
|
|
806
|
+
bc.add_source(name, *values)
|
|
807
|
+
return bc
|
|
808
|
+
|
|
809
|
+
@staticmethod
|
|
810
|
+
class GraphOp:
|
|
811
|
+
@staticmethod
|
|
812
|
+
def commit():
|
|
813
|
+
return Bytecode._create_graph_op("tx", "commit")
|
|
814
|
+
|
|
815
|
+
@staticmethod
|
|
816
|
+
def rollback():
|
|
817
|
+
return Bytecode._create_graph_op("tx", "rollback")
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
'''
|
|
821
|
+
BINDINGS
|
|
822
|
+
'''
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
class Bindings(object):
|
|
826
|
+
|
|
827
|
+
@staticmethod
|
|
828
|
+
def of(key, value):
|
|
829
|
+
if not isinstance(key, str):
|
|
830
|
+
raise TypeError("Key must be str")
|
|
831
|
+
return Binding(key, value)
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
class Binding(object):
|
|
835
|
+
def __init__(self, key, value):
|
|
836
|
+
self.key = key
|
|
837
|
+
self.value = value
|
|
838
|
+
|
|
839
|
+
def __eq__(self, other):
|
|
840
|
+
return isinstance(other, self.__class__) and self.key == other.key and self.value == other.value
|
|
841
|
+
|
|
842
|
+
def __hash__(self):
|
|
843
|
+
return hash(self.key) + hash(self.value)
|
|
844
|
+
|
|
845
|
+
def __repr__(self):
|
|
846
|
+
return "binding[" + self.key + "=" + str(self.value) + "]"
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
'''
|
|
850
|
+
WITH OPTIONS
|
|
851
|
+
'''
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
class WithOptions(object):
|
|
855
|
+
|
|
856
|
+
tokens = "~tinkerpop.valueMap.tokens"
|
|
857
|
+
|
|
858
|
+
none = 0
|
|
859
|
+
|
|
860
|
+
ids = 1
|
|
861
|
+
|
|
862
|
+
labels = 2
|
|
863
|
+
|
|
864
|
+
keys = 4
|
|
865
|
+
|
|
866
|
+
values = 8
|
|
867
|
+
|
|
868
|
+
all = 15
|
|
869
|
+
|
|
870
|
+
indexer = "~tinkerpop.index.indexer"
|
|
871
|
+
|
|
872
|
+
list = 0
|
|
873
|
+
|
|
874
|
+
map = 1
|
|
875
|
+
|