From f160bc19e96682f5c7906c574ae6f623eedf5d66 Mon Sep 17 00:00:00 2001 From: Leifur Halldor Asgeirsson Date: Thu, 7 Jul 2016 15:34:08 -0400 Subject: [PATCH 1/2] Make implicit relative imports explicit Implicit relative imports break python3 compatibility. This commit replaces implicit relative imports with explicit relative imports, which are supported by both python 2 (>= 2.6) and python 3. --- .../main/jython/gremlin_python/__init__.py | 2 +- .../jython/gremlin_python/driver/__init__.py | 4 +-- .../driver/rest_remote_connection.py | 2 +- .../jython/gremlin_python/process/__init__.py | 34 +++++++++---------- .../gremlin_python/process/graph_traversal.py | 6 ++-- .../process/groovy_translator.py | 10 +++--- .../process/jython_translator.py | 16 ++++----- .../gremlin_python/structure/__init__.py | 4 +-- .../gremlin_python/structure/remote_graph.py | 2 +- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/gremlin-python/src/main/jython/gremlin_python/__init__.py b/gremlin-python/src/main/jython/gremlin_python/__init__.py index cd21e560a3b..518d8e008b2 100644 --- a/gremlin-python/src/main/jython/gremlin_python/__init__.py +++ b/gremlin-python/src/main/jython/gremlin_python/__init__.py @@ -16,6 +16,6 @@ specific language governing permissions and limitations under the License. ''' -import statics +from . import statics __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py b/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py index bb4e612a0ba..7e1c0f1a812 100644 --- a/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py +++ b/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. ''' -from remote_connection import RemoteConnection -from rest_remote_connection import RESTRemoteConnection +from .remote_connection import RemoteConnection +from .rest_remote_connection import RESTRemoteConnection __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/rest_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/rest_remote_connection.py index b827d0d5f1f..6d967f8268e 100644 --- a/gremlin-python/src/main/jython/gremlin_python/driver/rest_remote_connection.py +++ b/gremlin-python/src/main/jython/gremlin_python/driver/rest_remote_connection.py @@ -20,7 +20,7 @@ import requests from gremlin_python.process.traversal import Traverser -from remote_connection import RemoteConnection +from .remote_connection import RemoteConnection __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' diff --git a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py index d84b097ac11..e93356e9572 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py @@ -17,22 +17,22 @@ under the License. ''' -from graph_traversal import GraphTraversal -from graph_traversal import GraphTraversalSource -from graph_traversal import __ -from groovy_translator import GroovyTranslator -from jython_translator import JythonTranslator -from traversal import Barrier -from traversal import Bytecode -from traversal import Cardinality -from traversal import Column -from traversal import Direction -from traversal import Operator -from traversal import Order -from traversal import P -from traversal import Pop -from traversal import Scope -from traversal import T -from traversal import Traversal +from .graph_traversal import GraphTraversal +from .graph_traversal import GraphTraversalSource +from .graph_traversal import __ +from .groovy_translator import GroovyTranslator +from .jython_translator import JythonTranslator +from .traversal import Barrier +from .traversal import Bytecode +from .traversal import Cardinality +from .traversal import Column +from .traversal import Direction +from .traversal import Operator +from .traversal import Order +from .traversal import P +from .traversal import Pop +from .traversal import Scope +from .traversal import T +from .traversal import Traversal __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py index 2261e83acf5..7a0fe2393d2 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py @@ -16,9 +16,9 @@ specific language governing permissions and limitations under the License. ''' -from traversal import RawExpression -from traversal import Traversal -from traversal import Bytecode +from .traversal import RawExpression +from .traversal import Traversal +from .traversal import Bytecode from gremlin_python import statics class GraphTraversalSource(object): diff --git a/gremlin-python/src/main/jython/gremlin_python/process/groovy_translator.py b/gremlin-python/src/main/jython/gremlin_python/process/groovy_translator.py index a05885d83d0..2c2d79a860d 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/groovy_translator.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/groovy_translator.py @@ -20,11 +20,11 @@ import sys from aenum import Enum -from traversal import Bytecode -from traversal import P -from traversal import RawExpression -from traversal import SymbolHelper -from traversal import Translator +from .traversal import Bytecode +from .traversal import P +from .traversal import RawExpression +from .traversal import SymbolHelper +from .traversal import Translator if sys.version_info.major > 2: long = int diff --git a/gremlin-python/src/main/jython/gremlin_python/process/jython_translator.py b/gremlin-python/src/main/jython/gremlin_python/process/jython_translator.py index 0ffcaabf8a5..11174ad95c5 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/jython_translator.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/jython_translator.py @@ -21,14 +21,14 @@ import sys from aenum import Enum -from traversal import Barrier -from traversal import Bytecode -from traversal import Cardinality -from traversal import Column -from traversal import P -from traversal import RawExpression -from traversal import SymbolHelper -from traversal import Translator +from .traversal import Barrier +from .traversal import Bytecode +from .traversal import Cardinality +from .traversal import Column +from .traversal import P +from .traversal import RawExpression +from .traversal import SymbolHelper +from .traversal import Translator if sys.version_info.major > 2: long = int diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py b/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py index fe9ad179920..1c69b5c0e00 100644 --- a/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py +++ b/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. ''' -from graph import Graph -from remote_graph import RemoteGraph +from .graph import Graph +from .remote_graph import RemoteGraph __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/remote_graph.py b/gremlin-python/src/main/jython/gremlin_python/structure/remote_graph.py index bc2a11aef03..778895b24a4 100644 --- a/gremlin-python/src/main/jython/gremlin_python/structure/remote_graph.py +++ b/gremlin-python/src/main/jython/gremlin_python/structure/remote_graph.py @@ -19,7 +19,7 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)' -from graph import Graph +from .graph import Graph from gremlin_python.process.traversal import TraversalStrategies from gremlin_python.process.traversal import TraversalStrategy From ed984aa127e02ba173455bfa14e17cb78abaf89a Mon Sep 17 00:00:00 2001 From: Leifur Halldor Asgeirsson Date: Tue, 9 Aug 2016 17:27:22 -0400 Subject: [PATCH 2/2] explicit relative imports in generated python code --- .../gremlin/python/GraphTraversalSourceGenerator.groovy | 6 +++--- .../gremlin/python/TraversalSourceGenerator.groovy | 2 +- .../main/jython/gremlin_python/process/graph_traversal.py | 6 +++--- .../src/main/jython/gremlin_python/process/traversal.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy index 61b9d577120..75f8beb03e9 100644 --- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy +++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy @@ -56,9 +56,9 @@ specific language governing permissions and limitations under the License. ''' """) - pythonClass.append("from traversal import Traversal\n") - pythonClass.append("from traversal import Bytecode\n") - pythonClass.append("from gremlin_python import statics\n\n") + pythonClass.append("from .traversal import Traversal\n") + pythonClass.append("from .traversal import Bytecode\n") + pythonClass.append("from .. import statics\n\n") ////////////////////////// // GraphTraversalSource // diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy index 59d09a49b1f..12eeed53517 100644 --- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy +++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy @@ -55,7 +55,7 @@ under the License. """) pythonClass.append("from abc import abstractmethod\n") pythonClass.append("from aenum import Enum\n") - pythonClass.append("from gremlin_python import statics\n") + pythonClass.append("from .. import statics\n") pythonClass.append(""" class Traversal(object): diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py index 98031396560..62900656f3b 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py @@ -16,9 +16,9 @@ specific language governing permissions and limitations under the License. ''' -from traversal import Traversal -from traversal import Bytecode -from gremlin_python import statics +from .traversal import Traversal +from .traversal import Bytecode +from .. import statics class GraphTraversalSource(object): def __init__(self, graph, traversal_strategies, bytecode=None): diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py index 3703e5d11af..9ae5afe58fe 100644 --- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py +++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py @@ -18,7 +18,7 @@ ''' from abc import abstractmethod from aenum import Enum -from gremlin_python import statics +from .. import statics class Traversal(object): def __init__(self, graph, traversal_strategies, bytecode):