tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [1/2] tinkerpop git commit: Cleanup of Python code in groovy traversal generator
Date Tue, 23 Aug 2016 17:37:37 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 1cdf2d9a3 -> d25e29b41


Cleanup of Python code in groovy traversal generator


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e1a558dd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e1a558dd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e1a558dd

Branch: refs/heads/TINKERPOP-1278
Commit: e1a558dd79f70848df73149dc8a369c7d3ea02b0
Parents: e6f4cfd
Author: davebshow <davebshow@gmail.com>
Authored: Tue Aug 23 12:00:53 2016 -0400
Committer: davebshow <davebshow@gmail.com>
Committed: Tue Aug 23 12:00:53 2016 -0400

----------------------------------------------------------------------
 .../gremlin/python/TraversalSourceGenerator.groovy      | 12 +++++-------
 .../src/main/jython/gremlin_python/process/traversal.py | 10 ++++------
 2 files changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1a558dd/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
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 4bab256..742c609 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
@@ -53,7 +53,8 @@ specific language governing permissions and limitations
 under the License.
 '''
 """)
-        pythonClass.append("from abc import abstractmethod\n")
+        pythonClass.append("import abc\n")
+        pythonClass.append("import six\n")
         pythonClass.append("from aenum import Enum\n")
         pythonClass.append("from .. import statics\n")
 
@@ -189,17 +190,16 @@ class TraversalStrategies(object):
     global_cache = {}
     def __init__(self, traversal_strategies=None):
         self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies
is not None else []
-        return
     def add_strategies(self, traversal_strategies):
         self.traversal_strategies = self.traversal_strategies + traversal_strategies
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
-        return
 
 
+@six.add_metaclass(abc.ABCMeta)
 class TraversalStrategy(object):
-    @abstractmethod
+    @abc.abstractmethod
     def apply(self, traversal):
         return
 
@@ -220,13 +220,11 @@ class Bytecode(object):
         for arg in args:
             instruction.append(self.__convertArgument(arg))
         self.source_instructions.append(instruction)
-        return
     def add_step(self, step_name, *args):
         instruction = [step_name]
         for arg in args:
             instruction.append(self.__convertArgument(arg))
         self.step_instructions.append(instruction)
-        return
     def __convertArgument(self,arg):
         if isinstance(arg, Traversal):
             self.bindings.update(arg.bytecode.bindings)
@@ -264,4 +262,4 @@ class Binding(object):
         file.delete()
         pythonClass.eachLine { file.append(it + "\n") }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1a558dd/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
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 4aa8e4d..2531efb 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -16,7 +16,8 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-from abc import abstractmethod
+import abc
+import six
 from aenum import Enum
 from .. import statics
 
@@ -247,17 +248,16 @@ class TraversalStrategies(object):
     global_cache = {}
     def __init__(self, traversal_strategies=None):
         self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies
is not None else []
-        return
     def add_strategies(self, traversal_strategies):
         self.traversal_strategies = self.traversal_strategies + traversal_strategies
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
-        return
 
 
+@six.add_metaclass(abc.ABCMeta)
 class TraversalStrategy(object):
-    @abstractmethod
+    @abc.abstractmethod
     def apply(self, traversal):
         return
 
@@ -278,13 +278,11 @@ class Bytecode(object):
         for arg in args:
             instruction.append(self.__convertArgument(arg))
         self.source_instructions.append(instruction)
-        return
     def add_step(self, step_name, *args):
         instruction = [step_name]
         for arg in args:
             instruction.append(self.__convertArgument(arg))
         self.step_instructions.append(instruction)
-        return
     def __convertArgument(self,arg):
         if isinstance(arg, Traversal):
             self.bindings.update(arg.bytecode.bindings)


Mime
View raw message