gremlinpython 3.7.6__tar.gz → 3.8.1__tar.gz
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.
- {gremlinpython-3.7.6/gremlinpython.egg-info → gremlinpython-3.8.1}/PKG-INFO +3 -3
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/__init__.py +1 -1
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/useragent.py +1 -1
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/anonymous_traversal.py +9 -12
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/graph_traversal.py +52 -31
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/strategies.py +38 -5
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/traversal.py +44 -3
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/statics.py +39 -1
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/graph.py +1 -13
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/io/graphbinaryV1.py +47 -3
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/io/graphsonV2d0.py +32 -26
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/io/graphsonV3d0.py +31 -28
- {gremlinpython-3.7.6 → gremlinpython-3.8.1/gremlinpython.egg-info}/PKG-INFO +3 -3
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlinpython.egg-info/requires.txt +1 -1
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/pyproject.toml +2 -2
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/LICENSE +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/MANIFEST.in +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/NOTICE +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/README.rst +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/__init__.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/aiohttp/__init__.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/aiohttp/transport.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/client.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/connection.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/driver_remote_connection.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/protocol.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/remote_connection.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/request.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/resultset.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/serializer.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/transport.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/__init__.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/process/translator.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/__init__.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/io/__init__.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/structure/io/util.py +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlinpython.egg-info/SOURCES.txt +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlinpython.egg-info/dependency_links.txt +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlinpython.egg-info/top_level.txt +0 -0
- {gremlinpython-3.7.6 → gremlinpython-3.8.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gremlinpython
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.1
|
|
4
4
|
Summary: Gremlin-Python for Apache TinkerPop
|
|
5
5
|
Maintainer-email: Apache TinkerPop <dev@tinkerpop.apache.org>
|
|
6
6
|
License: Apache 2
|
|
@@ -9,7 +9,7 @@ Classifier: Intended Audience :: Developers
|
|
|
9
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Classifier: Natural Language :: English
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/x-rst
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
License-File: NOTICE
|
|
@@ -23,7 +23,7 @@ Requires-Dist: kerberos<2.0.0,>=1.3.0; extra == "kerberos"
|
|
|
23
23
|
Provides-Extra: ujson
|
|
24
24
|
Requires-Dist: ujson>=2.0.0; extra == "ujson"
|
|
25
25
|
Provides-Extra: test
|
|
26
|
-
Requires-Dist: pytest<
|
|
26
|
+
Requires-Dist: pytest<8.0.0,>=6.2.5; extra == "test"
|
|
27
27
|
Requires-Dist: radish-bdd==0.18.2; extra == "test"
|
|
28
28
|
Requires-Dist: lxml==5.3.0; extra == "test"
|
|
29
29
|
Requires-Dist: PyHamcrest<3.0.0,>=1.9.0; extra == "test"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#
|
|
19
19
|
import platform
|
|
20
20
|
|
|
21
|
-
gremlin_version = "3.
|
|
21
|
+
gremlin_version = "3.8.1" # DO NOT MODIFY - Configured automatically by Maven Replacer Plugin
|
|
22
22
|
|
|
23
23
|
def _generate_user_agent():
|
|
24
24
|
application_name = "NotAvailable"
|
|
@@ -36,25 +36,22 @@ class AnonymousTraversalSource(object):
|
|
|
36
36
|
def traversal(cls, traversal_source_class=GraphTraversalSource):
|
|
37
37
|
return AnonymousTraversalSource(traversal_source_class)
|
|
38
38
|
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
"gremlin_python.process.AnonymousTraversalSource.withGraph will be replaced by "
|
|
42
|
-
"gremlin_python.process.AnonymousTraversalSource.with_graph.",
|
|
43
|
-
DeprecationWarning)
|
|
44
|
-
return self.with_graph(graph)
|
|
45
|
-
|
|
46
|
-
def with_graph(self, graph):
|
|
47
|
-
return self.traversal_source_class(graph, TraversalStrategies.global_cache[graph.__class__])
|
|
39
|
+
def with_(self, remote_connection):
|
|
40
|
+
return self.traversal_source_class(Graph(), TraversalStrategies(), None, remote_connection)
|
|
48
41
|
|
|
49
42
|
def withRemote(self, remote_connection):
|
|
50
43
|
warnings.warn(
|
|
51
44
|
"gremlin_python.process.AnonymousTraversalSource.withRemote will be replaced by "
|
|
52
|
-
"gremlin_python.process.AnonymousTraversalSource.
|
|
45
|
+
"gremlin_python.process.AnonymousTraversalSource.with_.",
|
|
53
46
|
DeprecationWarning)
|
|
54
|
-
return self.
|
|
47
|
+
return self.with_(remote_connection)
|
|
55
48
|
|
|
56
49
|
def with_remote(self, remote_connection):
|
|
57
|
-
|
|
50
|
+
warnings.warn(
|
|
51
|
+
"gremlin_python.process.AnonymousTraversalSource.with_remote will be replaced by "
|
|
52
|
+
"gremlin_python.process.AnonymousTraversalSource.with_.",
|
|
53
|
+
DeprecationWarning)
|
|
54
|
+
return self.with_(remote_connection)
|
|
58
55
|
|
|
59
56
|
|
|
60
57
|
def traversal(traversal_source_class=GraphTraversalSource):
|
|
@@ -35,7 +35,7 @@ __author__ = 'Stephen Mallette (http://stephen.genoprime.com), Lyndon Bauto (lyn
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class GraphTraversalSource(object):
|
|
38
|
-
def __init__(self, graph, traversal_strategies, bytecode=None):
|
|
38
|
+
def __init__(self, graph, traversal_strategies, bytecode=None, remote_connection=None):
|
|
39
39
|
log.info("Creating GraphTraversalSource.")
|
|
40
40
|
self.graph = graph
|
|
41
41
|
self.traversal_strategies = traversal_strategies
|
|
@@ -43,7 +43,9 @@ class GraphTraversalSource(object):
|
|
|
43
43
|
bytecode = Bytecode()
|
|
44
44
|
self.bytecode = bytecode
|
|
45
45
|
self.graph_traversal = GraphTraversal
|
|
46
|
-
|
|
46
|
+
if remote_connection:
|
|
47
|
+
self.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
|
|
48
|
+
self.remote_connection = remote_connection
|
|
47
49
|
|
|
48
50
|
def __repr__(self):
|
|
49
51
|
return "graphtraversalsource[" + str(self.graph) + "]"
|
|
@@ -133,26 +135,13 @@ class GraphTraversalSource(object):
|
|
|
133
135
|
|
|
134
136
|
val = True if v is None else v
|
|
135
137
|
if options_strategy is None:
|
|
136
|
-
options_strategy = OptionsStrategy({k: val})
|
|
138
|
+
options_strategy = OptionsStrategy(**{k: val})
|
|
137
139
|
source = self.with_strategies(options_strategy)
|
|
138
140
|
else:
|
|
139
141
|
options_strategy[1].configuration[k] = val
|
|
140
142
|
|
|
141
143
|
return source
|
|
142
144
|
|
|
143
|
-
def withRemote(self, remote_connection):
|
|
144
|
-
warnings.warn(
|
|
145
|
-
"gremlin_python.process.GraphTraversalSource.withRemote will be replaced by "
|
|
146
|
-
"gremlin_python.process.GraphTraversalSource.with_remote.",
|
|
147
|
-
DeprecationWarning)
|
|
148
|
-
return self.with_remote(remote_connection)
|
|
149
|
-
|
|
150
|
-
def with_remote(self, remote_connection):
|
|
151
|
-
source = self.get_graph_traversal_source()
|
|
152
|
-
source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
|
|
153
|
-
self.remote_connection = remote_connection
|
|
154
|
-
return source
|
|
155
|
-
|
|
156
145
|
def tx(self):
|
|
157
146
|
# In order to keep the constructor unchanged within 3.5.x we can try to pop the RemoteConnection out of the
|
|
158
147
|
# TraversalStrategies. keeping this unchanged will allow user DSLs to not take a break.
|
|
@@ -325,10 +314,18 @@ class GraphTraversal(Traversal):
|
|
|
325
314
|
self.bytecode.add_step("as", *args)
|
|
326
315
|
return self
|
|
327
316
|
|
|
317
|
+
def as_bool(self, *args):
|
|
318
|
+
self.bytecode.add_step("asBool", *args)
|
|
319
|
+
return self
|
|
320
|
+
|
|
328
321
|
def as_date(self, *args):
|
|
329
322
|
self.bytecode.add_step("asDate", *args)
|
|
330
323
|
return self
|
|
331
324
|
|
|
325
|
+
def as_number(self, *args):
|
|
326
|
+
self.bytecode.add_step("asNumber", *args)
|
|
327
|
+
return self
|
|
328
|
+
|
|
332
329
|
def as_string(self, *args):
|
|
333
330
|
self.bytecode.add_step("asString", *args)
|
|
334
331
|
return self
|
|
@@ -449,6 +446,10 @@ class GraphTraversal(Traversal):
|
|
|
449
446
|
self.bytecode.add_step("difference", *args)
|
|
450
447
|
return self
|
|
451
448
|
|
|
449
|
+
def discard(self, *args):
|
|
450
|
+
self.bytecode.add_step("discard", *args)
|
|
451
|
+
return self
|
|
452
|
+
|
|
452
453
|
def disjunct(self, *args):
|
|
453
454
|
self.bytecode.add_step("disjunct", *args)
|
|
454
455
|
return self
|
|
@@ -555,6 +556,10 @@ class GraphTraversal(Traversal):
|
|
|
555
556
|
self.bytecode.add_step("hasKey", *args)
|
|
556
557
|
return self
|
|
557
558
|
|
|
559
|
+
def has_key(self, *args):
|
|
560
|
+
self.bytecode.add_step("hasKey", *args)
|
|
561
|
+
return self
|
|
562
|
+
|
|
558
563
|
def hasLabel(self, *args):
|
|
559
564
|
warnings.warn(
|
|
560
565
|
"gremlin_python.process.GraphTraversalSource.hasLabel will be replaced by "
|
|
@@ -909,10 +914,6 @@ class GraphTraversal(Traversal):
|
|
|
909
914
|
self.bytecode.add_step("split", *args)
|
|
910
915
|
return self
|
|
911
916
|
|
|
912
|
-
def store(self, *args):
|
|
913
|
-
self.bytecode.add_step("store", *args)
|
|
914
|
-
return self
|
|
915
|
-
|
|
916
917
|
def subgraph(self, *args):
|
|
917
918
|
self.bytecode.add_step("subgraph", *args)
|
|
918
919
|
return self
|
|
@@ -1102,10 +1103,18 @@ class __(object, metaclass=MagicType):
|
|
|
1102
1103
|
def as_(cls, *args):
|
|
1103
1104
|
return cls.graph_traversal(None, None, Bytecode()).as_(*args)
|
|
1104
1105
|
|
|
1106
|
+
@classmethod
|
|
1107
|
+
def as_bool(cls, *args):
|
|
1108
|
+
return cls.graph_traversal(None, None, Bytecode()).as_bool(*args)
|
|
1109
|
+
|
|
1105
1110
|
@classmethod
|
|
1106
1111
|
def as_date(cls, *args):
|
|
1107
1112
|
return cls.graph_traversal(None, None, Bytecode()).as_date(*args)
|
|
1108
1113
|
|
|
1114
|
+
@classmethod
|
|
1115
|
+
def as_number(cls, *args):
|
|
1116
|
+
return cls.graph_traversal(None, None, Bytecode()).as_number(*args)
|
|
1117
|
+
|
|
1109
1118
|
@classmethod
|
|
1110
1119
|
def as_string(cls, *args):
|
|
1111
1120
|
return cls.graph_traversal(None, None, Bytecode()).as_string(*args)
|
|
@@ -1214,6 +1223,10 @@ class __(object, metaclass=MagicType):
|
|
|
1214
1223
|
def difference(cls, *args):
|
|
1215
1224
|
return cls.graph_traversal(None, None, Bytecode()).difference(*args)
|
|
1216
1225
|
|
|
1226
|
+
@classmethod
|
|
1227
|
+
def discard(cls, *args):
|
|
1228
|
+
return cls.graph_traversal(None, None, Bytecode()).discard(*args)
|
|
1229
|
+
|
|
1217
1230
|
@classmethod
|
|
1218
1231
|
def disjunct(cls, *args):
|
|
1219
1232
|
return cls.graph_traversal(None, None, Bytecode()).disjunct(*args)
|
|
@@ -1441,7 +1454,7 @@ class __(object, metaclass=MagicType):
|
|
|
1441
1454
|
"gremlin_python.process.__.l_trim.",
|
|
1442
1455
|
DeprecationWarning)
|
|
1443
1456
|
return cls.l_trim(*args)
|
|
1444
|
-
|
|
1457
|
+
|
|
1445
1458
|
@classmethod
|
|
1446
1459
|
def l_trim(cls, *args):
|
|
1447
1460
|
return cls.graph_traversal(None, None, Bytecode()).l_trim(*args)
|
|
@@ -1646,10 +1659,6 @@ class __(object, metaclass=MagicType):
|
|
|
1646
1659
|
def split(cls, *args):
|
|
1647
1660
|
return cls.graph_traversal(None, None, Bytecode()).split(*args)
|
|
1648
1661
|
|
|
1649
|
-
@classmethod
|
|
1650
|
-
def store(cls, *args):
|
|
1651
|
-
return cls.graph_traversal(None, None, Bytecode()).store(*args)
|
|
1652
|
-
|
|
1653
1662
|
@classmethod
|
|
1654
1663
|
def subgraph(cls, *args):
|
|
1655
1664
|
return cls.graph_traversal(None, None, Bytecode()).subgraph(*args)
|
|
@@ -1882,10 +1891,18 @@ def as_(*args):
|
|
|
1882
1891
|
return __.as_(*args)
|
|
1883
1892
|
|
|
1884
1893
|
|
|
1894
|
+
def as_bool(*args):
|
|
1895
|
+
return __.as_bool(*args)
|
|
1896
|
+
|
|
1897
|
+
|
|
1885
1898
|
def as_date(*args):
|
|
1886
1899
|
return __.as_date(*args)
|
|
1887
1900
|
|
|
1888
1901
|
|
|
1902
|
+
def as_number(*args):
|
|
1903
|
+
return __.as_number(*args)
|
|
1904
|
+
|
|
1905
|
+
|
|
1889
1906
|
def as_string(*args):
|
|
1890
1907
|
return __.as_string(*args)
|
|
1891
1908
|
|
|
@@ -1982,6 +1999,10 @@ def difference(*args):
|
|
|
1982
1999
|
return __.difference(*args)
|
|
1983
2000
|
|
|
1984
2001
|
|
|
2002
|
+
def discard(*args):
|
|
2003
|
+
return __.discard(*args)
|
|
2004
|
+
|
|
2005
|
+
|
|
1985
2006
|
def disjunct(*args):
|
|
1986
2007
|
return __.disjunct(*args)
|
|
1987
2008
|
|
|
@@ -2336,10 +2357,6 @@ def split(*args):
|
|
|
2336
2357
|
return __.split(*args)
|
|
2337
2358
|
|
|
2338
2359
|
|
|
2339
|
-
def store(*args):
|
|
2340
|
-
return __.store(*args)
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
2360
|
def subgraph(*args):
|
|
2344
2361
|
return __.subgraph(*args)
|
|
2345
2362
|
|
|
@@ -2457,8 +2474,12 @@ statics.add_static('any_', any_)
|
|
|
2457
2474
|
|
|
2458
2475
|
statics.add_static('as_', as_)
|
|
2459
2476
|
|
|
2477
|
+
statics.add_static('as_bool', as_bool)
|
|
2478
|
+
|
|
2460
2479
|
statics.add_static('as_date', as_date)
|
|
2461
2480
|
|
|
2481
|
+
statics.add_static('as_number', as_number)
|
|
2482
|
+
|
|
2462
2483
|
statics.add_static('as_string', as_string)
|
|
2463
2484
|
|
|
2464
2485
|
statics.add_static('barrier', barrier)
|
|
@@ -2507,6 +2528,8 @@ statics.add_static('dedup', dedup)
|
|
|
2507
2528
|
|
|
2508
2529
|
statics.add_static('difference', difference)
|
|
2509
2530
|
|
|
2531
|
+
statics.add_static('discard', discard)
|
|
2532
|
+
|
|
2510
2533
|
statics.add_static('disjunct', disjunct)
|
|
2511
2534
|
|
|
2512
2535
|
statics.add_static('drop', drop)
|
|
@@ -2681,8 +2704,6 @@ statics.add_static('skip', skip)
|
|
|
2681
2704
|
|
|
2682
2705
|
statics.add_static('split', split)
|
|
2683
2706
|
|
|
2684
|
-
statics.add_static('store', store)
|
|
2685
|
-
|
|
2686
2707
|
statics.add_static('subgraph', subgraph)
|
|
2687
2708
|
|
|
2688
2709
|
statics.add_static('substring', substring)
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
|
|
21
21
|
|
|
22
|
-
from
|
|
22
|
+
from .traversal import TraversalStrategy
|
|
23
23
|
|
|
24
24
|
base_namespace = 'org.apache.tinkerpop.gremlin.process.traversal.strategy.'
|
|
25
25
|
decoration_namespace = base_namespace + 'decoration.'
|
|
@@ -41,6 +41,7 @@ class ConnectiveStrategy(TraversalStrategy):
|
|
|
41
41
|
class ElementIdStrategy(TraversalStrategy):
|
|
42
42
|
def __init__(self):
|
|
43
43
|
TraversalStrategy.__init__(self, fqcn=decoration_namespace + 'ElementIdStrategy')
|
|
44
|
+
self.configuration = {}
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
# EventStrategy doesn't make sense outside JVM traversal machine
|
|
@@ -53,7 +54,7 @@ class HaltedTraverserStrategy(TraversalStrategy):
|
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
class OptionsStrategy(TraversalStrategy):
|
|
56
|
-
def __init__(self, options
|
|
57
|
+
def __init__(self, **options):
|
|
57
58
|
TraversalStrategy.__init__(self, configuration=options, fqcn=decoration_namespace + 'OptionsStrategy')
|
|
58
59
|
|
|
59
60
|
|
|
@@ -87,7 +88,7 @@ class SubgraphStrategy(TraversalStrategy):
|
|
|
87
88
|
if vertex_properties is not None:
|
|
88
89
|
self.configuration["vertexProperties"] = vertex_properties
|
|
89
90
|
if check_adjacent_vertices is not None:
|
|
90
|
-
self.configuration["
|
|
91
|
+
self.configuration["checkAdjacentVertices"] = check_adjacent_vertices
|
|
91
92
|
|
|
92
93
|
|
|
93
94
|
class VertexProgramStrategy(TraversalStrategy):
|
|
@@ -109,6 +110,19 @@ class VertexProgramStrategy(TraversalStrategy):
|
|
|
109
110
|
if configuration is not None:
|
|
110
111
|
self.configuration.update(configuration)
|
|
111
112
|
|
|
113
|
+
class ReferenceElementStrategy(TraversalStrategy):
|
|
114
|
+
def __init__(self, options=None):
|
|
115
|
+
TraversalStrategy.__init__(self, configuration=options, fqcn=decoration_namespace + 'ReferenceElementStrategy')
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class ComputerFinalizationStrategy(TraversalStrategy):
|
|
119
|
+
def __init__(self, options=None):
|
|
120
|
+
TraversalStrategy.__init__(self, configuration=options, fqcn=decoration_namespace + 'ComputerFinalizationStrategy')
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class ProfileStrategy(TraversalStrategy):
|
|
124
|
+
def __init__(self, options=None):
|
|
125
|
+
TraversalStrategy.__init__(self, configuration=options, fqcn=decoration_namespace + 'ProfileStrategy')
|
|
112
126
|
|
|
113
127
|
###########################
|
|
114
128
|
# FINALIZATION STRATEGIES #
|
|
@@ -132,12 +146,12 @@ class AdjacentToIncidentStrategy(TraversalStrategy):
|
|
|
132
146
|
|
|
133
147
|
class ByModulatorOptimizationStrategy(TraversalStrategy):
|
|
134
148
|
def __init__(self):
|
|
135
|
-
TraversalStrategy.__init__(self, fqcn=
|
|
149
|
+
TraversalStrategy.__init__(self, fqcn=optimization_namespace + 'ByModulatorOptimizationStrategy')
|
|
136
150
|
|
|
137
151
|
|
|
138
152
|
class CountStrategy(TraversalStrategy):
|
|
139
153
|
def __init__(self):
|
|
140
|
-
TraversalStrategy.__init__(self, fqcn=
|
|
154
|
+
TraversalStrategy.__init__(self, fqcn=optimization_namespace + 'CountStrategy')
|
|
141
155
|
|
|
142
156
|
|
|
143
157
|
class FilterRankingStrategy(TraversalStrategy):
|
|
@@ -210,10 +224,19 @@ class EarlyLimitStrategy(TraversalStrategy):
|
|
|
210
224
|
def __init__(self):
|
|
211
225
|
TraversalStrategy.__init__(self, fqcn=optimization_namespace + 'EarlyLimitStrategy')
|
|
212
226
|
|
|
227
|
+
|
|
228
|
+
class MessagePassingReductionStrategy(TraversalStrategy):
|
|
229
|
+
def __init__(self, options=None):
|
|
230
|
+
TraversalStrategy.__init__(self, configuration=options, fqcn=optimization_namespace + 'MessagePassingReductionStrategy')
|
|
231
|
+
|
|
213
232
|
###########################
|
|
214
233
|
# VERIFICATION STRATEGIES #
|
|
215
234
|
###########################
|
|
216
235
|
|
|
236
|
+
class ComputerVerificationStrategy(TraversalStrategy):
|
|
237
|
+
def __init__(self, options=None):
|
|
238
|
+
TraversalStrategy.__init__(self, configuration=options, fqcn=verification_namespace + 'ComputerVerificationStrategy')
|
|
239
|
+
|
|
217
240
|
|
|
218
241
|
class LambdaRestrictionStrategy(TraversalStrategy):
|
|
219
242
|
def __init__(self):
|
|
@@ -237,3 +260,13 @@ class ReservedKeysVerificationStrategy(TraversalStrategy):
|
|
|
237
260
|
self.configuration["logWarning"] = log_warning
|
|
238
261
|
self.configuration["throwException"] = throw_exception
|
|
239
262
|
self.configuration["keys"] = keys
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class VertexProgramRestrictionStrategy(TraversalStrategy):
|
|
266
|
+
def __init__(self):
|
|
267
|
+
TraversalStrategy.__init__(self, fqcn=verification_namespace + 'VertexProgramRestrictionStrategy')
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class StandardVerificationStrategy(TraversalStrategy):
|
|
271
|
+
def __init__(self):
|
|
272
|
+
TraversalStrategy.__init__(self, fqcn=verification_namespace + 'StandardVerificationStrategy')
|
|
@@ -75,7 +75,7 @@ class Traversal(object):
|
|
|
75
75
|
return set(iter(self))
|
|
76
76
|
|
|
77
77
|
def iterate(self):
|
|
78
|
-
self.bytecode.add_step("
|
|
78
|
+
self.bytecode.add_step("discard")
|
|
79
79
|
while True:
|
|
80
80
|
try: self.next_traverser()
|
|
81
81
|
except StopIteration: return self
|
|
@@ -214,10 +214,11 @@ statics.add_static('shuffle', Order.shuffle)
|
|
|
214
214
|
statics.add_static('asc', Order.asc)
|
|
215
215
|
statics.add_static('desc', Order.desc)
|
|
216
216
|
|
|
217
|
-
Pick = Enum('Pick', ' any_ none')
|
|
217
|
+
Pick = Enum('Pick', ' any_ none unproductive')
|
|
218
218
|
|
|
219
219
|
statics.add_static('any_', Pick.any_)
|
|
220
220
|
statics.add_static('none', Pick.none)
|
|
221
|
+
statics.add_static('unproductive', Pick.unproductive)
|
|
221
222
|
|
|
222
223
|
Pop = Enum('Pop', ' all_ first last mixed')
|
|
223
224
|
|
|
@@ -258,6 +259,37 @@ statics.add_static('add_all', Operator.add_all)
|
|
|
258
259
|
statics.add_static('sum_long', Operator.sum_long)
|
|
259
260
|
|
|
260
261
|
|
|
262
|
+
GType = Enum('GType', ' BIGDECIMAL BIGINT BINARY BOOLEAN BYTE CHAR DATETIME DOUBLE DURATION EDGE FLOAT GRAPH INT LIST LONG MAP NULL NUMBER PATH PROPERTY SET SHORT STRING TREE UUID VERTEX VPROPERTY')
|
|
263
|
+
|
|
264
|
+
statics.add_static('BIGDECIMAL', GType.BIGDECIMAL)
|
|
265
|
+
statics.add_static('BIGINT', GType.BIGINT)
|
|
266
|
+
statics.add_static('BINARY', GType.BINARY)
|
|
267
|
+
statics.add_static('BOOLEAN', GType.BOOLEAN)
|
|
268
|
+
statics.add_static('BYTE', GType.BYTE)
|
|
269
|
+
statics.add_static('CHAR', GType.CHAR)
|
|
270
|
+
statics.add_static('DATETIME', GType.DATETIME)
|
|
271
|
+
statics.add_static('DOUBLE', GType.DOUBLE)
|
|
272
|
+
statics.add_static('DURATION', GType.DURATION)
|
|
273
|
+
statics.add_static('EDGE', GType.EDGE)
|
|
274
|
+
statics.add_static('FLOAT', GType.FLOAT)
|
|
275
|
+
statics.add_static('GRAPH', GType.GRAPH)
|
|
276
|
+
statics.add_static('INT', GType.INT)
|
|
277
|
+
statics.add_static('LIST', GType.LIST)
|
|
278
|
+
statics.add_static('LONG', GType.LONG)
|
|
279
|
+
statics.add_static('MAP', GType.MAP)
|
|
280
|
+
statics.add_static('NULL', GType.NULL)
|
|
281
|
+
statics.add_static('NUMBER', GType.NUMBER)
|
|
282
|
+
statics.add_static('PATH', GType.PATH)
|
|
283
|
+
statics.add_static('PROPERTY', GType.PROPERTY)
|
|
284
|
+
statics.add_static('SET', GType.SET)
|
|
285
|
+
statics.add_static('SHORT', GType.SHORT)
|
|
286
|
+
statics.add_static('STRING', GType.STRING)
|
|
287
|
+
statics.add_static('TREE', GType.TREE)
|
|
288
|
+
statics.add_static('UUID', GType.UUID)
|
|
289
|
+
statics.add_static('VERTEX', GType.VERTEX)
|
|
290
|
+
statics.add_static('VPROPERTY', GType.VPROPERTY)
|
|
291
|
+
|
|
292
|
+
|
|
261
293
|
class P(object):
|
|
262
294
|
def __init__(self, operator, value, other=None):
|
|
263
295
|
self.operator = operator
|
|
@@ -308,6 +340,10 @@ class P(object):
|
|
|
308
340
|
def test(*args):
|
|
309
341
|
return P("test", *args)
|
|
310
342
|
|
|
343
|
+
@staticmethod
|
|
344
|
+
def type_of(*args):
|
|
345
|
+
return P("typeOf", *args)
|
|
346
|
+
|
|
311
347
|
@staticmethod
|
|
312
348
|
def within(*args):
|
|
313
349
|
if len(args) == 1 and type(args[0]) == list:
|
|
@@ -387,6 +423,10 @@ def without(*args):
|
|
|
387
423
|
return P.without(*args)
|
|
388
424
|
|
|
389
425
|
|
|
426
|
+
def type_of(*args):
|
|
427
|
+
return P.type_of(*args)
|
|
428
|
+
|
|
429
|
+
|
|
390
430
|
statics.add_static('between', between)
|
|
391
431
|
|
|
392
432
|
statics.add_static('eq', eq)
|
|
@@ -411,6 +451,8 @@ statics.add_static('within', within)
|
|
|
411
451
|
|
|
412
452
|
statics.add_static('without', without)
|
|
413
453
|
|
|
454
|
+
statics.add_static('typeOf', type_of)
|
|
455
|
+
|
|
414
456
|
|
|
415
457
|
class TextP(P):
|
|
416
458
|
def __init__(self, operator, value, other=None):
|
|
@@ -688,7 +730,6 @@ TRAVERSAL STRATEGIES
|
|
|
688
730
|
|
|
689
731
|
|
|
690
732
|
class TraversalStrategies(object):
|
|
691
|
-
global_cache = {}
|
|
692
733
|
|
|
693
734
|
def __init__(self, traversal_strategies=None):
|
|
694
735
|
self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies is not None else []
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# specific language governing permissions and limitations
|
|
17
17
|
# under the License.
|
|
18
18
|
#
|
|
19
|
-
|
|
19
|
+
import decimal
|
|
20
20
|
from types import FunctionType
|
|
21
21
|
from aenum import Enum
|
|
22
22
|
|
|
@@ -84,10 +84,48 @@ class GremlinType(object):
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
class BigDecimal(object):
|
|
87
|
+
"""
|
|
88
|
+
Provides a way to represent a BigDecimal for Gremlin.
|
|
89
|
+
"""
|
|
87
90
|
def __init__(self, scale, unscaled_value):
|
|
88
91
|
self.scale = scale
|
|
89
92
|
self.unscaled_value = unscaled_value
|
|
90
93
|
|
|
94
|
+
@property
|
|
95
|
+
def value(self):
|
|
96
|
+
self._as_decimal = decimal.Decimal(self.unscaled_value)
|
|
97
|
+
precision = len(self._as_decimal.as_tuple().digits)
|
|
98
|
+
with decimal.localcontext(decimal.Context(prec=precision)):
|
|
99
|
+
return self._as_decimal.scaleb(-self.scale)
|
|
100
|
+
|
|
101
|
+
def __eq__(self, other):
|
|
102
|
+
if not isinstance(other, BigDecimal):
|
|
103
|
+
return False
|
|
104
|
+
return self.scale == other.scale and self.unscaled_value == other.unscaled_value
|
|
105
|
+
|
|
106
|
+
def __hash__(self):
|
|
107
|
+
return hash((self.scale, self.unscaled_value))
|
|
108
|
+
|
|
109
|
+
def __repr__(self):
|
|
110
|
+
return f"BigDecimal(scale={self.scale}, unscaled_value={self.unscaled_value})"
|
|
111
|
+
|
|
112
|
+
def __str__(self):
|
|
113
|
+
return str(self.value)
|
|
114
|
+
|
|
115
|
+
"""
|
|
116
|
+
Create a BigDecimal from a number that can be converted to a Decimal. Note precision may be lost during the conversion.
|
|
117
|
+
"""
|
|
118
|
+
def bigdecimal(value):
|
|
119
|
+
try:
|
|
120
|
+
decimal_value = value if isinstance(value, decimal.Decimal) else decimal.Decimal(str(value))
|
|
121
|
+
scale = -decimal_value.as_tuple().exponent
|
|
122
|
+
unscaled_value = int("".join(map(str, decimal_value.as_tuple().digits)))
|
|
123
|
+
except TypeError:
|
|
124
|
+
raise ValueError("BigDecimal does not support NaN, Infinity or -Infinity")
|
|
125
|
+
except Exception as err:
|
|
126
|
+
raise ValueError(f'Encountered error: {err}. Value must be able to convert to a Decimal.')
|
|
127
|
+
return BigDecimal(scale, unscaled_value if decimal_value >= 0 else -unscaled_value)
|
|
128
|
+
|
|
91
129
|
|
|
92
130
|
staticMethods = {}
|
|
93
131
|
staticEnums = {}
|
|
@@ -25,18 +25,6 @@ import warnings
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class Graph(object):
|
|
28
|
-
def __init__(self):
|
|
29
|
-
if self.__class__ not in TraversalStrategies.global_cache:
|
|
30
|
-
TraversalStrategies.global_cache[self.__class__] = TraversalStrategies()
|
|
31
|
-
|
|
32
|
-
def traversal(self, traversal_source_class=None):
|
|
33
|
-
warnings.warn(
|
|
34
|
-
"As of release 3.3.5, replaced by the gremlin_python.process.anonymous_traversal.traversal() function.",
|
|
35
|
-
DeprecationWarning)
|
|
36
|
-
|
|
37
|
-
if not traversal_source_class:
|
|
38
|
-
traversal_source_class = GraphTraversalSource
|
|
39
|
-
return traversal_source_class(self, TraversalStrategies.global_cache[self.__class__])
|
|
40
28
|
|
|
41
29
|
def __repr__(self):
|
|
42
30
|
return "graph[]"
|
|
@@ -46,7 +34,7 @@ class Element(object):
|
|
|
46
34
|
def __init__(self, id, label, properties=None):
|
|
47
35
|
self.id = id
|
|
48
36
|
self.label = label
|
|
49
|
-
self.properties = properties
|
|
37
|
+
self.properties = [] if properties is None else properties
|
|
50
38
|
|
|
51
39
|
def __eq__(self, other):
|
|
52
40
|
return isinstance(other, self.__class__) and self.id == other.id
|
|
@@ -33,8 +33,8 @@ from gremlin_python import statics
|
|
|
33
33
|
from gremlin_python.statics import FloatType, BigDecimal, FunctionType, ShortType, IntType, LongType, BigIntType, \
|
|
34
34
|
TypeType, DictType, ListType, SetType, SingleByte, ByteBufferType, GremlinType, \
|
|
35
35
|
SingleChar
|
|
36
|
-
from gremlin_python.process.traversal import Barrier, Binding, Bytecode, Cardinality, Column, Direction, DT,
|
|
37
|
-
Operator, Order, Pick, Pop, P, Scope, TextP, Traversal, Traverser, \
|
|
36
|
+
from gremlin_python.process.traversal import Barrier, Binding, Bytecode, Cardinality, Column, Direction, DT, GType, \
|
|
37
|
+
Merge,Operator, Order, Pick, Pop, P, Scope, TextP, Traversal, Traverser, \
|
|
38
38
|
TraversalStrategy, T
|
|
39
39
|
from gremlin_python.process.graph_traversal import GraphTraversal
|
|
40
40
|
from gremlin_python.structure.graph import Graph, Edge, Property, Vertex, VertexProperty, Path
|
|
@@ -98,6 +98,7 @@ class DataType(Enum):
|
|
|
98
98
|
traversalmetrics = 0x2d
|
|
99
99
|
merge = 0x2e
|
|
100
100
|
dt = 0x2f
|
|
101
|
+
gtype = 0x30
|
|
101
102
|
char = 0x80
|
|
102
103
|
duration = 0x81
|
|
103
104
|
inetaddress = 0x82 # todo
|
|
@@ -106,7 +107,7 @@ class DataType(Enum):
|
|
|
106
107
|
localdatetime = 0x85 # todo
|
|
107
108
|
localtime = 0x86 # todo
|
|
108
109
|
monthday = 0x87 # todo
|
|
109
|
-
offsetdatetime = 0x88
|
|
110
|
+
offsetdatetime = 0x88
|
|
110
111
|
offsettime = 0x89 # todo
|
|
111
112
|
period = 0x8a # todo
|
|
112
113
|
year = 0x8b # todo
|
|
@@ -343,6 +344,44 @@ class DateIO(_GraphBinaryTypeIO):
|
|
|
343
344
|
nullable)
|
|
344
345
|
|
|
345
346
|
|
|
347
|
+
class OffsetDateTimeIO(_GraphBinaryTypeIO):
|
|
348
|
+
|
|
349
|
+
python_type = datetime.datetime
|
|
350
|
+
graphbinary_type = DataType.offsetdatetime
|
|
351
|
+
|
|
352
|
+
@classmethod
|
|
353
|
+
def dictify(cls, obj, writer, to_extend, as_value=False, nullable=True):
|
|
354
|
+
if obj.tzinfo is None:
|
|
355
|
+
return DateIO.dictify(obj, writer, to_extend, as_value, nullable)
|
|
356
|
+
cls.prefix_bytes(cls.graphbinary_type, as_value, nullable, to_extend)
|
|
357
|
+
IntIO.dictify(obj.year, writer, to_extend, True, False)
|
|
358
|
+
ByteIO.dictify(obj.month, writer, to_extend, True, False)
|
|
359
|
+
ByteIO.dictify(obj.day, writer, to_extend, True, False)
|
|
360
|
+
# construct time of day in nanoseconds
|
|
361
|
+
h = obj.time().hour
|
|
362
|
+
m = obj.time().minute
|
|
363
|
+
s = obj.time().second
|
|
364
|
+
ms = obj.time().microsecond
|
|
365
|
+
ns = round((h*60*60*1e9) + (m*60*1e9) + (s*1e9) + (ms*1e3))
|
|
366
|
+
LongIO.dictify(ns, writer, to_extend, True, False)
|
|
367
|
+
os = round(obj.utcoffset().total_seconds())
|
|
368
|
+
IntIO.dictify(os, writer, to_extend, True, False)
|
|
369
|
+
return to_extend
|
|
370
|
+
|
|
371
|
+
@classmethod
|
|
372
|
+
def objectify(cls, buff, reader, nullable=True):
|
|
373
|
+
return cls.is_null(buff, reader, cls._read_dt, nullable)
|
|
374
|
+
|
|
375
|
+
@classmethod
|
|
376
|
+
def _read_dt(cls, b, r):
|
|
377
|
+
year = r.to_object(b, DataType.int, False)
|
|
378
|
+
month = r.to_object(b, DataType.byte, False)
|
|
379
|
+
day = r.to_object(b, DataType.byte, False)
|
|
380
|
+
ns = r.to_object(b, DataType.long, False)
|
|
381
|
+
offset = r.to_object(b, DataType.int, False)
|
|
382
|
+
tz = datetime.timezone(timedelta(seconds=offset))
|
|
383
|
+
return datetime.datetime(year, month, day, tzinfo=tz) + timedelta(microseconds=ns/1000)
|
|
384
|
+
|
|
346
385
|
# Based on current implementation, this class must always be declared before FloatIO.
|
|
347
386
|
# Seems pretty fragile for future maintainers. Maybe look into this.
|
|
348
387
|
class TimestampIO(_GraphBinaryTypeIO):
|
|
@@ -955,6 +994,11 @@ class TIO(_EnumIO):
|
|
|
955
994
|
python_type = T
|
|
956
995
|
|
|
957
996
|
|
|
997
|
+
class GTYPEIO(_EnumIO):
|
|
998
|
+
graphbinary_type = DataType.gtype
|
|
999
|
+
python_type = GType
|
|
1000
|
+
|
|
1001
|
+
|
|
958
1002
|
class TraverserIO(_GraphBinaryTypeIO):
|
|
959
1003
|
graphbinary_type = DataType.traverser
|
|
960
1004
|
python_type = Traverser
|
|
@@ -30,7 +30,8 @@ from aenum import Enum
|
|
|
30
30
|
from isodate import parse_duration, duration_isoformat
|
|
31
31
|
|
|
32
32
|
from gremlin_python import statics
|
|
33
|
-
from gremlin_python.statics import FloatType, FunctionType, ShortType, IntType, LongType, TypeType, SingleByte,
|
|
33
|
+
from gremlin_python.statics import FloatType, FunctionType, ShortType, IntType, LongType, TypeType, SingleByte, \
|
|
34
|
+
ByteBufferType, SingleChar, BigDecimal, bigdecimal
|
|
34
35
|
from gremlin_python.process.traversal import Binding, Bytecode, P, TextP, Traversal, Traverser, TraversalStrategy
|
|
35
36
|
from gremlin_python.structure.graph import Edge, Property, Vertex, VertexProperty, Path
|
|
36
37
|
from gremlin_python.structure.io.util import SymbolUtil
|
|
@@ -236,7 +237,12 @@ class TraversalStrategySerializer(_GraphSONTypeIO):
|
|
|
236
237
|
|
|
237
238
|
@classmethod
|
|
238
239
|
def dictify(cls, strategy, writer):
|
|
239
|
-
|
|
240
|
+
strat_dict = {}
|
|
241
|
+
strat_dict["fqcn"] = strategy.fqcn
|
|
242
|
+
strat_dict["conf"] = {}
|
|
243
|
+
for key in strategy.configuration:
|
|
244
|
+
strat_dict["conf"][key] = writer.to_dict(strategy.configuration[key])
|
|
245
|
+
return GraphSONUtil.typed_value(strategy.strategy_name, strat_dict)
|
|
240
246
|
|
|
241
247
|
|
|
242
248
|
class TraverserIO(_GraphSONTypeIO):
|
|
@@ -339,7 +345,6 @@ class UUIDIO(_GraphSONTypeIO):
|
|
|
339
345
|
|
|
340
346
|
|
|
341
347
|
class DateIO(_GraphSONTypeIO):
|
|
342
|
-
python_type = datetime.datetime
|
|
343
348
|
graphson_type = "g:Date"
|
|
344
349
|
graphson_base_type = "Date"
|
|
345
350
|
|
|
@@ -360,6 +365,24 @@ class DateIO(_GraphSONTypeIO):
|
|
|
360
365
|
return datetime.datetime.utcfromtimestamp(ts / 1000.0)
|
|
361
366
|
|
|
362
367
|
|
|
368
|
+
class OffsetDateTimeIO(_GraphSONTypeIO):
|
|
369
|
+
python_type = datetime.datetime
|
|
370
|
+
graphson_type = "gx:OffsetDateTime"
|
|
371
|
+
graphson_base_type = "OffsetDateTime"
|
|
372
|
+
|
|
373
|
+
@classmethod
|
|
374
|
+
def dictify(cls, obj, writer):
|
|
375
|
+
if obj.tzinfo is None:
|
|
376
|
+
return DateIO.dictify(obj, writer)
|
|
377
|
+
return GraphSONUtil.typed_value(cls.graphson_base_type, obj.isoformat(), "gx")
|
|
378
|
+
|
|
379
|
+
@classmethod
|
|
380
|
+
def objectify(cls, dt, reader):
|
|
381
|
+
# specially handling as python isoformat does not support zulu until 3.11
|
|
382
|
+
dt_iso = dt[:-1] + '+00:00' if dt.endswith('Z') else dt
|
|
383
|
+
return datetime.datetime.fromisoformat(dt_iso)
|
|
384
|
+
|
|
385
|
+
|
|
363
386
|
# Based on current implementation, this class must always be declared before FloatIO.
|
|
364
387
|
# Seems pretty fragile for future maintainers. Maybe look into this.
|
|
365
388
|
class TimestampIO(_GraphSONTypeIO):
|
|
@@ -425,34 +448,17 @@ class FloatIO(_NumberIO):
|
|
|
425
448
|
|
|
426
449
|
|
|
427
450
|
class BigDecimalIO(_NumberIO):
|
|
428
|
-
python_type =
|
|
451
|
+
python_type = BigDecimal
|
|
429
452
|
graphson_type = "gx:BigDecimal"
|
|
430
453
|
graphson_base_type = "BigDecimal"
|
|
431
454
|
|
|
432
455
|
@classmethod
|
|
433
456
|
def dictify(cls, n, writer):
|
|
434
|
-
|
|
435
|
-
return n
|
|
436
|
-
elif math.isnan(n):
|
|
437
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "NaN", "gx")
|
|
438
|
-
elif math.isinf(n) and n > 0:
|
|
439
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "Infinity", "gx")
|
|
440
|
-
elif math.isinf(n) and n < 0:
|
|
441
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "-Infinity", "gx")
|
|
442
|
-
else:
|
|
443
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, str(n), "gx")
|
|
457
|
+
return GraphSONUtil.typed_value(cls.graphson_base_type, str(n.value), "gx")
|
|
444
458
|
|
|
445
459
|
@classmethod
|
|
446
460
|
def objectify(cls, v, _):
|
|
447
|
-
|
|
448
|
-
if v == 'NaN':
|
|
449
|
-
return Decimal('nan')
|
|
450
|
-
elif v == "Infinity":
|
|
451
|
-
return Decimal('inf')
|
|
452
|
-
elif v == "-Infinity":
|
|
453
|
-
return Decimal('-inf')
|
|
454
|
-
|
|
455
|
-
return Decimal(v)
|
|
461
|
+
return bigdecimal(v)
|
|
456
462
|
|
|
457
463
|
|
|
458
464
|
class DoubleIO(FloatIO):
|
|
@@ -585,7 +591,7 @@ class VertexDeserializer(_GraphSONTypeIO):
|
|
|
585
591
|
|
|
586
592
|
@classmethod
|
|
587
593
|
def objectify(cls, d, reader):
|
|
588
|
-
properties =
|
|
594
|
+
properties = []
|
|
589
595
|
if "properties" in d:
|
|
590
596
|
properties = reader.to_object(d["properties"])
|
|
591
597
|
if properties is not None:
|
|
@@ -598,7 +604,7 @@ class EdgeDeserializer(_GraphSONTypeIO):
|
|
|
598
604
|
|
|
599
605
|
@classmethod
|
|
600
606
|
def objectify(cls, d, reader):
|
|
601
|
-
properties =
|
|
607
|
+
properties = []
|
|
602
608
|
if "properties" in d:
|
|
603
609
|
properties = reader.to_object(d["properties"])
|
|
604
610
|
if properties is not None:
|
|
@@ -615,7 +621,7 @@ class VertexPropertyDeserializer(_GraphSONTypeIO):
|
|
|
615
621
|
|
|
616
622
|
@classmethod
|
|
617
623
|
def objectify(cls, d, reader):
|
|
618
|
-
properties =
|
|
624
|
+
properties = []
|
|
619
625
|
if "properties" in d:
|
|
620
626
|
properties = reader.to_object(d["properties"])
|
|
621
627
|
if properties is not None:
|
|
@@ -29,7 +29,8 @@ from aenum import Enum
|
|
|
29
29
|
from isodate import parse_duration, duration_isoformat
|
|
30
30
|
|
|
31
31
|
from gremlin_python import statics
|
|
32
|
-
from gremlin_python.statics import FloatType, FunctionType, ShortType, IntType, LongType, TypeType, DictType, ListType,
|
|
32
|
+
from gremlin_python.statics import FloatType, FunctionType, ShortType, IntType, LongType, TypeType, DictType, ListType, \
|
|
33
|
+
SetType, SingleByte, ByteBufferType, SingleChar, BigDecimal, bigdecimal
|
|
33
34
|
from gremlin_python.process.traversal import Binding, Bytecode, Direction, P, TextP, Traversal, Traverser, TraversalStrategy, T
|
|
34
35
|
from gremlin_python.structure.graph import Edge, Property, Vertex, VertexProperty, Path
|
|
35
36
|
from gremlin_python.structure.io.util import HashableDict, SymbolUtil
|
|
@@ -240,10 +241,12 @@ class TraversalStrategySerializer(_GraphSONTypeIO):
|
|
|
240
241
|
|
|
241
242
|
@classmethod
|
|
242
243
|
def dictify(cls, strategy, writer):
|
|
243
|
-
|
|
244
|
+
strat_dict = {}
|
|
245
|
+
strat_dict["fqcn"] = strategy.fqcn
|
|
246
|
+
strat_dict["conf"] = {}
|
|
244
247
|
for key in strategy.configuration:
|
|
245
|
-
|
|
246
|
-
return GraphSONUtil.typed_value(strategy.strategy_name,
|
|
248
|
+
strat_dict["conf"][key] = writer.to_dict(strategy.configuration[key])
|
|
249
|
+
return GraphSONUtil.typed_value(strategy.strategy_name, strat_dict)
|
|
247
250
|
|
|
248
251
|
|
|
249
252
|
class TraverserIO(_GraphSONTypeIO):
|
|
@@ -346,7 +349,6 @@ class UUIDIO(_GraphSONTypeIO):
|
|
|
346
349
|
|
|
347
350
|
|
|
348
351
|
class DateIO(_GraphSONTypeIO):
|
|
349
|
-
python_type = datetime.datetime
|
|
350
352
|
graphson_type = "g:Date"
|
|
351
353
|
graphson_base_type = "Date"
|
|
352
354
|
|
|
@@ -367,6 +369,24 @@ class DateIO(_GraphSONTypeIO):
|
|
|
367
369
|
return datetime.datetime.utcfromtimestamp(ts / 1000.0)
|
|
368
370
|
|
|
369
371
|
|
|
372
|
+
class OffsetDateTimeIO(_GraphSONTypeIO):
|
|
373
|
+
python_type = datetime.datetime
|
|
374
|
+
graphson_type = "gx:OffsetDateTime"
|
|
375
|
+
graphson_base_type = "OffsetDateTime"
|
|
376
|
+
|
|
377
|
+
@classmethod
|
|
378
|
+
def dictify(cls, obj, writer):
|
|
379
|
+
if obj.tzinfo is None:
|
|
380
|
+
return DateIO.dictify(obj, writer)
|
|
381
|
+
return GraphSONUtil.typed_value(cls.graphson_base_type, obj.isoformat(), "gx")
|
|
382
|
+
|
|
383
|
+
@classmethod
|
|
384
|
+
def objectify(cls, dt, reader):
|
|
385
|
+
# specially handling as python isoformat does not support zulu until 3.11
|
|
386
|
+
dt_iso = dt[:-1] + '+00:00' if dt.endswith('Z') else dt
|
|
387
|
+
return datetime.datetime.fromisoformat(dt_iso)
|
|
388
|
+
|
|
389
|
+
|
|
370
390
|
# Based on current implementation, this class must always be declared before FloatIO.
|
|
371
391
|
# Seems pretty fragile for future maintainers. Maybe look into this.
|
|
372
392
|
class TimestampIO(_GraphSONTypeIO):
|
|
@@ -534,34 +554,17 @@ class FloatIO(_NumberIO):
|
|
|
534
554
|
|
|
535
555
|
|
|
536
556
|
class BigDecimalIO(_NumberIO):
|
|
537
|
-
python_type =
|
|
557
|
+
python_type = BigDecimal
|
|
538
558
|
graphson_type = "gx:BigDecimal"
|
|
539
559
|
graphson_base_type = "BigDecimal"
|
|
540
560
|
|
|
541
561
|
@classmethod
|
|
542
562
|
def dictify(cls, n, writer):
|
|
543
|
-
|
|
544
|
-
return n
|
|
545
|
-
elif math.isnan(n):
|
|
546
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "NaN", "gx")
|
|
547
|
-
elif math.isinf(n) and n > 0:
|
|
548
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "Infinity", "gx")
|
|
549
|
-
elif math.isinf(n) and n < 0:
|
|
550
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, "-Infinity", "gx")
|
|
551
|
-
else:
|
|
552
|
-
return GraphSONUtil.typed_value(cls.graphson_base_type, str(n), "gx")
|
|
563
|
+
return GraphSONUtil.typed_value(cls.graphson_base_type, str(n.value), "gx")
|
|
553
564
|
|
|
554
565
|
@classmethod
|
|
555
566
|
def objectify(cls, v, _):
|
|
556
|
-
|
|
557
|
-
if v == 'NaN':
|
|
558
|
-
return Decimal('nan')
|
|
559
|
-
elif v == "Infinity":
|
|
560
|
-
return Decimal('inf')
|
|
561
|
-
elif v == "-Infinity":
|
|
562
|
-
return Decimal('-inf')
|
|
563
|
-
|
|
564
|
-
return Decimal(v)
|
|
567
|
+
return bigdecimal(v)
|
|
565
568
|
|
|
566
569
|
|
|
567
570
|
class DoubleIO(FloatIO):
|
|
@@ -694,7 +697,7 @@ class VertexDeserializer(_GraphSONTypeIO):
|
|
|
694
697
|
|
|
695
698
|
@classmethod
|
|
696
699
|
def objectify(cls, d, reader):
|
|
697
|
-
properties =
|
|
700
|
+
properties = []
|
|
698
701
|
if "properties" in d:
|
|
699
702
|
properties = reader.to_object(d["properties"])
|
|
700
703
|
if properties is not None:
|
|
@@ -707,7 +710,7 @@ class EdgeDeserializer(_GraphSONTypeIO):
|
|
|
707
710
|
|
|
708
711
|
@classmethod
|
|
709
712
|
def objectify(cls, d, reader):
|
|
710
|
-
properties =
|
|
713
|
+
properties = []
|
|
711
714
|
if "properties" in d:
|
|
712
715
|
properties = reader.to_object(d["properties"])
|
|
713
716
|
if properties is not None:
|
|
@@ -724,7 +727,7 @@ class VertexPropertyDeserializer(_GraphSONTypeIO):
|
|
|
724
727
|
|
|
725
728
|
@classmethod
|
|
726
729
|
def objectify(cls, d, reader):
|
|
727
|
-
properties =
|
|
730
|
+
properties = []
|
|
728
731
|
if "properties" in d:
|
|
729
732
|
properties = reader.to_object(d["properties"])
|
|
730
733
|
if properties is not None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gremlinpython
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.1
|
|
4
4
|
Summary: Gremlin-Python for Apache TinkerPop
|
|
5
5
|
Maintainer-email: Apache TinkerPop <dev@tinkerpop.apache.org>
|
|
6
6
|
License: Apache 2
|
|
@@ -9,7 +9,7 @@ Classifier: Intended Audience :: Developers
|
|
|
9
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Classifier: Natural Language :: English
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/x-rst
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
License-File: NOTICE
|
|
@@ -23,7 +23,7 @@ Requires-Dist: kerberos<2.0.0,>=1.3.0; extra == "kerberos"
|
|
|
23
23
|
Provides-Extra: ujson
|
|
24
24
|
Requires-Dist: ujson>=2.0.0; extra == "ujson"
|
|
25
25
|
Provides-Extra: test
|
|
26
|
-
Requires-Dist: pytest<
|
|
26
|
+
Requires-Dist: pytest<8.0.0,>=6.2.5; extra == "test"
|
|
27
27
|
Requires-Dist: radish-bdd==0.18.2; extra == "test"
|
|
28
28
|
Requires-Dist: lxml==5.3.0; extra == "test"
|
|
29
29
|
Requires-Dist: PyHamcrest<3.0.0,>=1.9.0; extra == "test"
|
|
@@ -26,7 +26,7 @@ description = "Gremlin-Python for Apache TinkerPop"
|
|
|
26
26
|
readme = {file = "README.rst", content-type = "text/x-rst"}
|
|
27
27
|
license = {text = "Apache 2"}
|
|
28
28
|
maintainers = [{name = "Apache TinkerPop", email = "dev@tinkerpop.apache.org"}]
|
|
29
|
-
requires-python = ">=3.
|
|
29
|
+
requires-python = ">=3.10"
|
|
30
30
|
dependencies = [
|
|
31
31
|
"nest_asyncio",
|
|
32
32
|
"aiohttp>=3.8.0,<4.0.0",
|
|
@@ -48,7 +48,7 @@ Homepage = "https://tinkerpop.apache.org"
|
|
|
48
48
|
kerberos = ["kerberos>=1.3.0,<2.0.0"]
|
|
49
49
|
ujson = ["ujson>=2.0.0"]
|
|
50
50
|
test = [
|
|
51
|
-
"pytest>=
|
|
51
|
+
"pytest>=6.2.5,<8.0.0",
|
|
52
52
|
"radish-bdd==0.18.2",
|
|
53
53
|
"lxml==5.3.0",
|
|
54
54
|
"PyHamcrest>=1.9.0,<3.0.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gremlinpython-3.7.6 → gremlinpython-3.8.1}/gremlin_python/driver/driver_remote_connection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|