You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/06/22 20:50:23 UTC
[6/6] tinkerpop git commit: removed gremlin-variants/ and created
gremlin-python. Reorganized lots of things given new insights. A few sucky
things to work out. Need @spmallette help -- packaging,
testing issues. Really cool stuff.
removed gremlin-variants/ and created gremlin-python. Reorganized lots of things given new insights. A few sucky things to work out. Need @spmallette help -- packaging, testing issues. Really cool stuff.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/49674539
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/49674539
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/49674539
Branch: refs/heads/TINKERPOP-1278
Commit: 4967453974ea72152a665d5b2f87080c053af7c4
Parents: 2fb26e4
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Jun 22 14:50:11 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Jun 22 14:50:11 2016 -0600
----------------------------------------------------------------------
docs/preprocessor/awk/init-code-blocks.awk | 2 +-
.../gremlin/groovy/GroovyTranslatorTest.java | 1 +
.../AbstractImportCustomizerProvider.java | 1 +
.../gremlin/groovy/GroovyTranslator.java | 172 --
.../java/translator/GroovyTranslator.java | 172 ++
gremlin-python/pom.xml | 334 ++++
.../python/GremlinPythonSourceGenerator.groovy | 312 +++
.../java/translator/PythonTranslator.java | 218 +++
.../gremlin/python/GenerateGremlinPython.java | 33 +
.../jsr223/GremlinJythonScriptEngine.java | 126 ++
.../GremlinJythonScriptEngineFactory.java | 115 ++
gremlin-python/src/main/jython/LICENSE | 202 ++
gremlin-python/src/main/jython/MANIFEST.in | 18 +
gremlin-python/src/main/jython/NOTICE | 5 +
gremlin-python/src/main/jython/README | 18 +
.../src/main/jython/gremlin_driver/__init__.py | 22 +
.../jython/gremlin_driver/gremlin_driver.py | 39 +
.../src/main/jython/gremlin_python/__init__.py | 35 +
.../jython/gremlin_python/gremlin_python.py | 1832 ++++++++++++++++++
.../jython/gremlin_python/groovy_translator.py | 121 ++
.../main/jython/gremlin_python/translator.py | 49 +
.../main/jython/gremlin_rest_driver/__init__.py | 21 +
.../gremlin_rest_driver/gremlin_rest_driver.py | 41 +
gremlin-python/src/main/jython/setup.cfg | 18 +
gremlin-python/src/main/jython/setup.py | 58 +
.../java/translator/PythonBypassTranslator.java | 88 +
.../java/translator/PythonTranslatorTest.java | 93 +
...erGraphPythonTranslatorComputerProvider.java | 37 +
...raphPythonTranslatorProcessComputerTest.java | 34 +
...raphPythonTranslatorProcessStandardTest.java | 34 +
.../TinkerGraphPythonTranslatorProvider.java | 150 ++
.../python/driver/RESTRemoteConnectionTest.java | 66 +
.../jsr223/GremlinJythonScriptEngineSetup.java | 46 +
.../jsr223/GremlinJythonScriptEngineTest.java | 50 +
.../services/javax.script.ScriptEngineFactory | 1 +
.../src/test/resources/log4j-silent.properties | 23 +
.../src/test/resources/log4j-test.properties | 23 +
.../driver/gremlin-server-rest-modern.yaml | 45 +
.../RemoteGraphTranslatorComputerProvider.java | 54 -
.../remote/RemoteGraphTranslatorProvider.java | 35 -
...teGraphGroovyTranslatorComputerProvider.java | 54 +
...raphGroovyTranslatorProcessComputerTest.java | 33 +
...raphGroovyTranslatorProcessStandardTest.java | 33 +
.../RemoteGraphGroovyTranslatorProvider.java | 35 +
...emoteGraphTranslatorProcessComputerTest.java | 34 -
...emoteGraphTranslatorProcessStandardTest.java | 34 -
gremlin-variant/pom.xml | 334 ----
.../python/GremlinPythonGenerator.groovy | 314 ---
.../gremlin/python/GenerateGremlinPython.java | 33 -
.../gremlin/python/PythonTranslator.java | 218 ---
.../jsr223/GremlinJythonScriptEngine.java | 126 --
.../GremlinJythonScriptEngineFactory.java | 115 --
gremlin-variant/src/main/jython/LICENSE | 202 --
gremlin-variant/src/main/jython/MANIFEST.in | 18 -
gremlin-variant/src/main/jython/NOTICE | 5 -
gremlin-variant/src/main/jython/README | 18 -
.../src/main/jython/gremlin_driver/__init__.py | 22 -
.../jython/gremlin_driver/gremlin_driver.py | 39 -
.../src/main/jython/gremlin_python/__init__.py | 35 -
.../jython/gremlin_python/gremlin_python.py | 1832 ------------------
.../jython/gremlin_python/groovy_translator.py | 121 --
.../main/jython/gremlin_python/translator.py | 45 -
.../main/jython/gremlin_rest_driver/__init__.py | 21 -
.../gremlin_rest_driver/gremlin_rest_driver.py | 41 -
gremlin-variant/src/main/jython/setup.cfg | 18 -
gremlin-variant/src/main/jython/setup.py | 58 -
.../tinkerpop/gremlin/VariantGraphProvider.java | 128 --
.../gremlin/groovy/GroovyComputerProvider.java | 37 -
.../groovy/GroovyProcessComputerTest.java | 33 -
.../groovy/GroovyProcessStandardTest.java | 33 -
.../gremlin/groovy/GroovyProvider.java | 39 -
.../gremlin/python/JythonScriptEngineSetup.java | 46 -
.../gremlin/python/PythonBypassTranslator.java | 88 -
.../gremlin/python/PythonComputerProvider.java | 37 -
.../python/PythonProcessComputerTest.java | 34 -
.../python/PythonProcessStandardTest.java | 34 -
.../gremlin/python/PythonProvider.java | 61 -
.../gremlin/python/PythonTranslatorTest.java | 92 -
.../python/driver/RESTRemoteConnectionTest.java | 67 -
.../jsr223/GremlinJythonScriptEngineTest.java | 50 -
.../services/javax.script.ScriptEngineFactory | 2 -
.../src/test/resources/log4j-silent.properties | 23 -
.../src/test/resources/log4j-test.properties | 23 -
.../gremlin/gremlin-server-rest-modern.yaml | 45 -
pom.xml | 32 +-
...erGraphGroovyTranslatorComputerProvider.java | 37 +
...raphGroovyTranslatorProcessComputerTest.java | 33 +
...raphGroovyTranslatorProcessStandardTest.java | 33 +
.../TinkerGraphGroovyTranslatorProvider.java | 75 +
89 files changed, 4836 insertions(+), 4828 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/docs/preprocessor/awk/init-code-blocks.awk
----------------------------------------------------------------------
diff --git a/docs/preprocessor/awk/init-code-blocks.awk b/docs/preprocessor/awk/init-code-blocks.awk
index d9b9dc3..573c6d4 100644
--- a/docs/preprocessor/awk/init-code-blocks.awk
+++ b/docs/preprocessor/awk/init-code-blocks.awk
@@ -50,7 +50,7 @@ BEGIN {
print "if (f.exists()) f.deleteDir()"
print ":set max-iteration 100"
if (lang == "python") {
- print "import org.apache.tinkerpop.gremlin.python.PythonTranslator"
+ print "import org.apache.tinkerpop.gremlin.java.translator.PythonTranslator"
print "import javax.script.ScriptEngineManager"
print "import javax.script.SimpleBindings"
print "def downloadFile(String url, final String localPath) {"
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
index 6d1dafc..14f75bb 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.groovy;
import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.java.translator.GroovyTranslator;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
index 61884b1..3f7eec2 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
@@ -23,6 +23,7 @@ import groovy.json.JsonBuilder;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.groovy.function.GFunction;
import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader;
+import org.apache.tinkerpop.gremlin.java.translator.GroovyTranslator;
import org.apache.tinkerpop.gremlin.process.computer.Computer;
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkDumperVertexProgram;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslator.java
deleted file mode 100644
index 9841479..0000000
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslator.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.groovy;
-
-import org.apache.tinkerpop.gremlin.process.computer.Computer;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.creation.TranslationStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
-import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
-import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
-import org.apache.tinkerpop.gremlin.process.traversal.util.Translator;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TranslatorHelper;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.function.Lambda;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class GroovyTranslator implements Translator {
-
- private StringBuilder traversalScript;
- private final String alias;
-
- private GroovyTranslator(final String alias) {
- this.alias = alias;
- this.traversalScript = new StringBuilder(this.alias);
- }
-
- public static final GroovyTranslator of(final String alias) {
- return new GroovyTranslator(alias);
- }
-
- @Override
- public String getSourceLanguage() {
- return "gremlin-java";
- }
-
- @Override
- public String getTargetLanguage() {
- return "gremlin-groovy";
- }
-
- @Override
- public String toString() {
- return StringFactory.translatorString(this);
- }
-
- @Override
- public String getAlias() {
- return this.alias;
- }
-
- @Override
- public void addStep(final Traversal.Admin<?, ?> traversal, final String stepName, final Object... arguments) {
- final List<Object> objects = TranslatorHelper.flattenArguments(arguments);
- if (objects.isEmpty())
- this.traversalScript.append(".").append(stepName).append("()");
- else {
- this.traversalScript.append(".");
- String temp = stepName + "(";
- for (final Object object : objects) {
- temp = temp + convertToString(object) + ",";
- }
- this.traversalScript.append(temp.substring(0, temp.length() - 1) + ")");
- }
- }
-
- @Override
- public Translator getAnonymousTraversalTranslator() {
- return new GroovyTranslator("__");
- }
-
- @Override
- public String getTraversalScript() {
- final String traversal = this.traversalScript.toString();
- if (traversal.contains("$"))
- throw new VerificationException("Lambdas are currently not supported: " + traversal, EmptyTraversal.instance());
- return traversal;
- }
-
- @Override
- public GroovyTranslator clone() {
- try {
- final GroovyTranslator clone = (GroovyTranslator) super.clone();
- clone.traversalScript = new StringBuilder(this.traversalScript);
- return clone;
- } catch (final CloneNotSupportedException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- ///////
-
- private static String convertToString(final Object object) {
- if (object instanceof String)
- return "\"" + object + "\"";
- else if (object instanceof List) {
- final List<String> list = new ArrayList<>(((List) object).size());
- for (final Object item : (List) object) {
- list.add(convertToString(item));
- }
- return list.toString();
- } else if (object instanceof Long)
- return object + "L";
- else if (object instanceof Double)
- return object + "d";
- else if (object instanceof Float)
- return object + "f";
- else if (object instanceof Integer)
- return "(int) " + object;
- else if (object instanceof Class)
- return ((Class) object).getCanonicalName();
- else if (object instanceof P)
- return convertPToString((P) object, new StringBuilder()).toString();
- else if (object instanceof SackFunctions.Barrier)
- return "SackFunctions.Barrier." + object.toString();
- else if (object instanceof VertexProperty.Cardinality)
- return "VertexProperty.Cardinality." + object.toString();
- else if (object instanceof Enum)
- return ((Enum) object).getDeclaringClass().getSimpleName() + "." + object.toString();
- else if (object instanceof Element)
- return convertToString(((Element) object).id()); // hack
- else if (object instanceof Computer) { // TODO: blow out
- return "";
- } else if (object instanceof Lambda) {
- final String lambdaString = ((Lambda) object).getLambdaScript();
- return lambdaString.startsWith("{") ? lambdaString : "{" + lambdaString + "}";
- } else if (object instanceof Traversal)
- return ((Traversal) object).asAdmin().getStrategies().getStrategy(TranslationStrategy.class).get().getTranslator().getTraversalScript();
- else
- return null == object ? "null" : object.toString();
- }
-
- private static StringBuilder convertPToString(final P p, final StringBuilder current) {
- if (p instanceof ConnectiveP) {
- final List<P<?>> list = ((ConnectiveP) p).getPredicates();
- for (int i = 0; i < list.size(); i++) {
- convertPToString(list.get(i), current);
- if (i < list.size() - 1)
- current.append(p instanceof OrP ? ".or(" : ".and(");
- }
- current.append(")");
- } else
- current.append("P.").append(p.getBiPredicate().toString()).append("(").append(convertToString(p.getValue())).append(")");
- return current;
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/java/translator/GroovyTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/java/translator/GroovyTranslator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/java/translator/GroovyTranslator.java
new file mode 100644
index 0000000..ead9df1
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/java/translator/GroovyTranslator.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.java.translator;
+
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.creation.TranslationStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
+import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
+import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
+import org.apache.tinkerpop.gremlin.process.traversal.util.Translator;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TranslatorHelper;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.function.Lambda;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class GroovyTranslator implements Translator {
+
+ private StringBuilder traversalScript;
+ private final String alias;
+
+ private GroovyTranslator(final String alias) {
+ this.alias = alias;
+ this.traversalScript = new StringBuilder(this.alias);
+ }
+
+ public static final GroovyTranslator of(final String alias) {
+ return new GroovyTranslator(alias);
+ }
+
+ @Override
+ public String getSourceLanguage() {
+ return "gremlin-java";
+ }
+
+ @Override
+ public String getTargetLanguage() {
+ return "gremlin-groovy";
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.translatorString(this);
+ }
+
+ @Override
+ public String getAlias() {
+ return this.alias;
+ }
+
+ @Override
+ public void addStep(final Traversal.Admin<?, ?> traversal, final String stepName, final Object... arguments) {
+ final List<Object> objects = TranslatorHelper.flattenArguments(arguments);
+ if (objects.isEmpty())
+ this.traversalScript.append(".").append(stepName).append("()");
+ else {
+ this.traversalScript.append(".");
+ String temp = stepName + "(";
+ for (final Object object : objects) {
+ temp = temp + convertToString(object) + ",";
+ }
+ this.traversalScript.append(temp.substring(0, temp.length() - 1) + ")");
+ }
+ }
+
+ @Override
+ public Translator getAnonymousTraversalTranslator() {
+ return new GroovyTranslator("__");
+ }
+
+ @Override
+ public String getTraversalScript() {
+ final String traversal = this.traversalScript.toString();
+ if (traversal.contains("$"))
+ throw new VerificationException("Lambdas are currently not supported: " + traversal, EmptyTraversal.instance());
+ return traversal;
+ }
+
+ @Override
+ public GroovyTranslator clone() {
+ try {
+ final GroovyTranslator clone = (GroovyTranslator) super.clone();
+ clone.traversalScript = new StringBuilder(this.traversalScript);
+ return clone;
+ } catch (final CloneNotSupportedException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ ///////
+
+ private static String convertToString(final Object object) {
+ if (object instanceof String)
+ return "\"" + object + "\"";
+ else if (object instanceof List) {
+ final List<String> list = new ArrayList<>(((List) object).size());
+ for (final Object item : (List) object) {
+ list.add(convertToString(item));
+ }
+ return list.toString();
+ } else if (object instanceof Long)
+ return object + "L";
+ else if (object instanceof Double)
+ return object + "d";
+ else if (object instanceof Float)
+ return object + "f";
+ else if (object instanceof Integer)
+ return "(int) " + object;
+ else if (object instanceof Class)
+ return ((Class) object).getCanonicalName();
+ else if (object instanceof P)
+ return convertPToString((P) object, new StringBuilder()).toString();
+ else if (object instanceof SackFunctions.Barrier)
+ return "SackFunctions.Barrier." + object.toString();
+ else if (object instanceof VertexProperty.Cardinality)
+ return "VertexProperty.Cardinality." + object.toString();
+ else if (object instanceof Enum)
+ return ((Enum) object).getDeclaringClass().getSimpleName() + "." + object.toString();
+ else if (object instanceof Element)
+ return convertToString(((Element) object).id()); // hack
+ else if (object instanceof Computer) { // TODO: blow out
+ return "";
+ } else if (object instanceof Lambda) {
+ final String lambdaString = ((Lambda) object).getLambdaScript();
+ return lambdaString.startsWith("{") ? lambdaString : "{" + lambdaString + "}";
+ } else if (object instanceof Traversal)
+ return ((Traversal) object).asAdmin().getStrategies().getStrategy(TranslationStrategy.class).get().getTranslator().getTraversalScript();
+ else
+ return null == object ? "null" : object.toString();
+ }
+
+ private static StringBuilder convertPToString(final P p, final StringBuilder current) {
+ if (p instanceof ConnectiveP) {
+ final List<P<?>> list = ((ConnectiveP) p).getPredicates();
+ for (int i = 0; i < list.size(); i++) {
+ convertPToString(list.get(i), current);
+ if (i < list.size() - 1)
+ current.append(p instanceof OrP ? ".or(" : ".and(");
+ }
+ current.append(")");
+ } else
+ current.append("P.").append(p.getBiPredicate().toString()).append("(").append(convertToString(p.getValue())).append(")");
+ return current;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
new file mode 100644
index 0000000..6c31ac4
--- /dev/null
+++ b/gremlin-python/pom.xml
@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkerpop</artifactId>
+ <version>3.2.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>gremlin-python</artifactId>
+ <name>Apache TinkerPop :: Gremlin Python</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ <classifier>indy</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython-standalone</artifactId>
+ <version>2.7.1b2</version>
+ </dependency>
+ <!-- TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <directory>${basedir}/target</directory>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources
+ </directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>${basedir}/src/test/resources
+ </directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <id>generatePython</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.apache.tinkerpop.gremlin.python.GenerateGremlinPython</mainClass>
+ <arguments>
+ <argument>${basedir}/src/main/jython/gremlin_python/gremlin_python.py</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>buildPython</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>python</executable>
+ <async>true</async>
+ <workingDirectory>${basedir}/src/main/jython</workingDirectory>
+ <commandlineArgs>setup.py build --build-lib ${project.build.testOutputDirectory}/Lib</commandlineArgs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>addSources</goal>
+ <goal>addTestSources</goal>
+ <goal>generateStubs</goal>
+ <goal>compile</goal>
+ <goal>testGenerateStubs</goal>
+ <goal>testCompile</goal>
+ <goal>removeStubs</goal>
+ <goal>removeTestStubs</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <invokeDynamic>true</invokeDynamic>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.sf.mavenjython</groupId>
+ <artifactId>jython-compile-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jython</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>pythonDependencies</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>jython</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+ <libraries>
+ <param>aenum</param>
+ <param>requests</param>
+ </libraries>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <python.home>${project.build.testOutputDirectory}</python.home>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}/src/main/jython/gremlin_rest_driver</directory>
+ <includes>
+ <include>**/*.pyc</include>
+ <include>**/*.class</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.py</exclude>
+ </excludes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <fileset>
+ <directory>${basedir}/src/main/jython/gremlin_driver</directory>
+ <includes>
+ <include>**/*.pyc</include>
+ <include>**/*.class</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.py</exclude>
+ </excludes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <fileset>
+ <directory>${basedir}/src/main/jython/gremlin_python</directory>
+ <includes>
+ <include>**/*.pyc</include>
+ <include>**/*.class</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.py</exclude>
+ </excludes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <!--
+ Provides a way to deploy the gremlinpython GLV to pypi. Requires installation of pip/virtualenv. See the
+ developer docs for more information on how to configure these settings to get this profile to work. The profile
+ largely uses antrun to execute raw pip/twine/python commands against a copy of what's in the jython directory
+ which is copied to target/py.
+ -->
+ <profile>
+ <id>glv-python</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>glvPython</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- copy files in jython directory to target/py and run virtual env to sandbox python -->
+ <execution>
+ <id>setup-py-env</id>
+ <phase>generate-resources</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${project.build.directory}/py/env"/>
+ <copy todir="${project.build.directory}/py">
+ <fileset dir="src/main/jython"/>
+ </copy>
+ <exec dir="${project.build.directory}/py" executable="virtualenv" failonerror="true">
+ <arg line="env"/>
+ </exec>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <!--
+ build/package python source distribution and wheel archive. the version is bound to an
+ environment variable that gets used in setup.py to dynamically construct a module
+ __version__file
+ -->
+ <execution>
+ <id>package-py</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <exec dir="${project.build.directory}/py" executable="env/bin/python" failonerror="true">
+ <env key="VERSION" value="${project.version}"/>
+ <arg line="setup.py sdist"/>
+ </exec>
+ <exec dir="${project.build.directory}/py" executable="env/bin/python" failonerror="true">
+ <env key="VERSION" value="${project.version}"/>
+ <arg line="setup.py bdist_wheel"/>
+ </exec>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <!-- deploy to pypi. assumes that ~/.pypirc is configured appropriately -->
+
+ <execution>
+ <id>deploy-py</id>
+ <phase>deploy</phase>
+ <configuration>
+ <tasks>
+ <exec dir="${project.build.directory}/py" executable="env/bin/pip" failonerror="true">
+ <arg line="install twine"/>
+ </exec>
+ <exec dir="${project.build.directory}/py" executable="env/bin/twine" failonerror="true">
+ <arg line="upload dist/* -r pypitest"/>
+ </exec>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonSourceGenerator.groovy
new file mode 100644
index 0000000..24bb703
--- /dev/null
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonSourceGenerator.groovy
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.python
+
+import org.apache.tinkerpop.gremlin.process.traversal.Operator
+import org.apache.tinkerpop.gremlin.process.traversal.Order
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.Pop
+import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions
+import org.apache.tinkerpop.gremlin.process.traversal.Scope
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import org.apache.tinkerpop.gremlin.structure.Column
+import org.apache.tinkerpop.gremlin.structure.Direction
+import org.apache.tinkerpop.gremlin.structure.T
+import org.apache.tinkerpop.gremlin.structure.VertexProperty
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+class GremlinPythonSourceGenerator {
+
+ public static void create(final String gremlinPythonFile) {
+
+ final StringBuilder pythonClass = new StringBuilder()
+
+ pythonClass.append("""'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+'''
+""")
+
+ final Map<String, String> methodMap = [global: "_global", as: "_as", in: "_in", and: "_and", or: "_or", is: "_is", not: "_not", from: "_from"]
+ .withDefault { it }
+ final Map<String, String> invertedMethodMap = [:].withDefault { it };
+ methodMap.entrySet().forEach { invertedMethodMap.put(it.value, it.key) }
+ final List<Class<? extends Enum>> enumList = [VertexProperty.Cardinality, Column, Direction, Operator, Order, Pop, SackFunctions.Barrier, Scope, T]
+
+ pythonClass.append("from collections import OrderedDict\n")
+ pythonClass.append("from aenum import Enum\n")
+ pythonClass.append("statics = OrderedDict()\n\n")
+ pythonClass.append("""
+globalTranslator = None
+""").append("\n\n");
+
+//////////////////////////
+// GraphTraversalSource //
+//////////////////////////
+ pythonClass.append(
+ """class PythonGraphTraversalSource(object):
+ def __init__(self, translator, remote_connection=None):
+ global globalTranslator
+ self.translator = translator
+ globalTranslator = translator
+ self.remote_connection = remote_connection
+ def __repr__(self):
+ return "graphtraversalsource[" + str(self.remote_connection) + ", " + self.translator.traversal_script + "]"
+""")
+ GraphTraversalSource.getMethods()
+ .findAll { !it.name.equals("clone") }
+ .collect { it.name }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .each { method ->
+ final Class<?> returnType = (GraphTraversalSource.getMethods() as Set).findAll {
+ it.name.equals(method)
+ }.collect {
+ it.returnType
+ }[0]
+ if (null != returnType) {
+ if (Traversal.isAssignableFrom(returnType)) {
+ pythonClass.append(
+ """ def ${method}(self, *args):
+ traversal = PythonGraphTraversal(self.translator, self.remote_connection)
+ traversal.translator.addSpawnStep(traversal, "${method}", *args)
+ for arg in args:
+ if isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str):
+ self.bindings[arg[0]] = arg[1]
+ elif isinstance(arg, RawExpression):
+ self.bindings.update(arg.bindings)
+ return traversal
+""")
+ } else if (TraversalSource.isAssignableFrom(returnType)) {
+ pythonClass.append(
+ """ def ${method}(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "${method}", *args)
+ for arg in args:
+ if isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str):
+ self.bindings[arg[0]] = arg[1]
+ elif isinstance(arg, RawExpression):
+ self.bindings.update(arg.bindings)
+ return source
+""")
+ }
+ }
+ }
+ pythonClass.append("\n\n")
+
+////////////////////
+// GraphTraversal //
+////////////////////
+ pythonClass.append(
+ """class PythonGraphTraversal(object):
+ def __init__(self, translator, remote_connection=None):
+ self.translator = translator
+ self.remote_connection = remote_connection
+ self.results = None
+ self.last_traverser = None
+ self.bindings = {}
+ def __repr__(self):
+ return self.translator.traversal_script
+ def __getitem__(self,index):
+ if isinstance(index,int):
+ return self.range(index,index+1)
+ elif isinstance(index,slice):
+ return self.range(index.start,index.stop)
+ else:
+ raise TypeError("Index must be int or slice")
+ def __getattr__(self,key):
+ return self.values(key)
+ def __iter__(self):
+ return self
+ def __next__(self):
+ return self.next()
+ def toList(self):
+ return list(iter(self))
+ def next(self):
+ if self.results is None:
+ self.results = self.remote_connection.submit(self.translator.target_language, self.translator.traversal_script, self.bindings)
+ if self.last_traverser is None:
+ self.last_traverser = next(self.results)
+ object = self.last_traverser.object
+ self.last_traverser.bulk = self.last_traverser.bulk - 1
+ if self.last_traverser.bulk <= 0:
+ self.last_traverser = None
+ return object
+""")
+ GraphTraversal.getMethods()
+ .findAll { !it.name.equals("clone") }
+ .collect { methodMap[it.name] }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .each { method ->
+ final Class<?> returnType = (GraphTraversal.getMethods() as Set).findAll {
+ it.name.equals(invertedMethodMap[method])
+ }.collect { it.returnType }[0]
+ if (null != returnType && Traversal.isAssignableFrom(returnType)) {
+ pythonClass.append(
+ """ def ${method}(self, *args):
+ self.translator.addStep(self, "${method}", *args)
+ for arg in args:
+ if isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str):
+ self.bindings[arg[0]] = arg[1]
+ elif isinstance(arg, RawExpression):
+ self.bindings.update(arg.bindings)
+ return self
+""")
+ }
+ };
+ pythonClass.append("\n\n")
+
+////////////////////////
+// AnonymousTraversal //
+////////////////////////
+ pythonClass.append("class __(object):\n");
+ __.getMethods()
+ .findAll { Traversal.isAssignableFrom(it.returnType) }
+ .collect { methodMap[it.name] }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .each { method ->
+ pythonClass.append(
+ """ @staticmethod
+ def ${method}(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).${method}(*args)
+""")
+ };
+ pythonClass.append("\n\n")
+
+ __.class.getMethods()
+ .findAll { Traversal.class.isAssignableFrom(it.getReturnType()) }
+ .findAll { !it.name.equals("__") && !it.name.equals("clone") }
+ .collect { methodMap[it.name] }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .forEach {
+ pythonClass.append("def ${it}(*args):\n").append(" return __.${it}(*args)\n\n")
+ pythonClass.append("statics['${it}'] = ${it}\n")
+ }
+ pythonClass.append("\n\n")
+
+///////////
+// Enums //
+///////////
+ for (final Class<? extends Enum> enumClass : enumList) {
+ pythonClass.append("${enumClass.getSimpleName()} = Enum('${enumClass.getSimpleName()}', '");
+ enumClass.getEnumConstants().each { value ->
+ pythonClass.append("${methodMap[value.name()]} ");
+ }
+ pythonClass.deleteCharAt(pythonClass.length() - 1).append("')\n\n")
+ enumClass.getEnumConstants().each { value ->
+ pythonClass.append("statics['${methodMap[value.name()]}'] = ${value.getDeclaringClass().getSimpleName()}.${methodMap[value.name()]}\n");
+ }
+ pythonClass.append("\n");
+ }
+ //////////////
+
+ pythonClass.append("""class RawExpression(object):
+ def __init__(self, *args):
+ self.bindings = dict()
+ self.parts = [self._process_arg(arg) for arg in args]
+
+ def _process_arg(self, arg):
+ if isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str):
+ self.bindings[arg[0]] = arg[1]
+ return Raw(arg[0])
+ else:
+ return Raw(arg)
+""")
+
+ pythonClass.append("\n")
+ pythonClass.append("""class Raw(object):
+ def __init__(self, value):
+ self.value = value
+
+ def __str__(self):
+ return str(self.value)
+""")
+
+ pythonClass.append("\n")
+
+ pythonClass.append("""class P(object):
+ def __init__(self, operator, value, other=None):
+ self.operator = operator
+ self.value = value
+ self.other = other
+""")
+ P.getMethods()
+ .findAll { P.class.isAssignableFrom(it.returnType) }
+ .findAll { !it.name.equals("or") && !it.name.equals("and") && !it.name.equals("clone") }
+ .collect { methodMap[it.name] }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .each { method ->
+ pythonClass.append(
+ """ @staticmethod
+ def ${method}(*args):
+ return P("${invertedMethodMap[method]}", *args)
+""")
+ };
+ pythonClass.append(""" def _and(self, arg):
+ return P("_and", arg, self)
+ def _or(self, arg):
+ return P("_or", arg, self)
+""")
+ pythonClass.append("\n")
+ P.class.getMethods()
+ .findAll { !it.name.equals("clone") }
+ .findAll { P.class.isAssignableFrom(it.getReturnType()) }
+ .collect { methodMap[it.name] }
+ .unique()
+ .sort { a, b -> a <=> b }
+ .forEach {
+ pythonClass.append("def ${it}(*args):\n").append(" return P.${it}(*args)\n\n")
+ pythonClass.append("statics['${it}'] = ${it}\n")
+ }
+ pythonClass.append("\n")
+ //////////////
+
+ pythonClass.append("statics = OrderedDict(reversed(list(statics.items())))\n")
+
+// save to a python file
+ final File file = new File(gremlinPythonFile);
+ file.delete()
+ pythonClass.eachLine { file.append(it + "\n") }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslator.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslator.java
new file mode 100644
index 0000000..b1007a6
--- /dev/null
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslator.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.java.translator;
+
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.traversal.Operator;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.creation.TranslationStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
+import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
+import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
+import org.apache.tinkerpop.gremlin.process.traversal.util.Translator;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TranslatorHelper;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.function.Lambda;
+import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class PythonTranslator implements Translator {
+
+ private static final Set<String> STEP_NAMES = Stream.of(GraphTraversal.class.getMethods()).filter(method -> Traversal.class.isAssignableFrom(method.getReturnType())).map(Method::getName).collect(Collectors.toSet());
+ private static final Set<String> PREFIX_NAMES = new HashSet<>(Arrays.asList("as", "in", "and", "or", "is", "not", "from", "global"));
+ private static final Set<String> NO_STATIC = Stream.of(T.values(), Operator.values())
+ .flatMap(arg -> IteratorUtils.stream(new ArrayIterator<>(arg)))
+ .map(arg -> ((Enum) arg).name())
+ .collect(Collectors.toCollection(() -> new HashSet<>(Arrays.asList("not"))));
+
+ protected StringBuilder traversalScript;
+ protected String alias;
+ protected final boolean importStatics;
+
+ PythonTranslator(final String alias, final boolean importStatics) {
+ this.alias = alias;
+ this.traversalScript = new StringBuilder(this.alias);
+ this.importStatics = importStatics;
+ }
+
+ public static PythonTranslator of(final String alias) {
+ return new PythonTranslator(alias, false);
+ }
+
+ public static PythonTranslator of(final String alias, final boolean importStatics) {
+ return new PythonTranslator(alias, importStatics);
+ }
+
+ @Override
+ public String getAlias() {
+ return this.alias;
+ }
+
+ @Override
+ public String getSourceLanguage() {
+ return "gremlin-java";
+ }
+
+ @Override
+ public String getTargetLanguage() {
+ return "gremlin-jython";
+ }
+
+ @Override
+ public Translator getAnonymousTraversalTranslator() {
+ return new PythonTranslator("__", this.importStatics);
+ }
+
+ @Override
+ public String getTraversalScript() {
+ final String traversal = this.traversalScript.toString();
+ if (traversal.contains("$"))
+ throw new VerificationException("Lambdas are currently not supported: " + traversal, EmptyTraversal.instance());
+ return traversal;
+ }
+
+ @Override
+ public void addStep(final Traversal.Admin<?, ?> traversal, final String stepName, final Object... arguments) {
+ // flatten the arguments into a single array
+ final List<Object> objects = TranslatorHelper.flattenArguments(arguments);
+ final int size = objects.size();
+ if (0 == size)
+ this.traversalScript.append(".").append(convertStepName(stepName)).append("()");
+ else if (stepName.equals("range") && 2 == size)
+ this.traversalScript.append("[").append(objects.get(0)).append(":").append(objects.get(1)).append("]");
+ else if (stepName.equals("limit") && 1 == size)
+ this.traversalScript.append("[0:").append(objects.get(0)).append("]");
+ else if (stepName.equals("values") && 1 == size && traversalScript.length() > 3 && !STEP_NAMES.contains(objects.get(0).toString()))
+ this.traversalScript.append(".").append(objects.get(0));
+ else {
+ this.traversalScript.append(".");
+ String temp = convertStepName(stepName) + "(";
+ for (final Object object : objects) {
+ temp = temp + convertToString(object) + ",";
+ }
+ this.traversalScript.append(temp.substring(0, temp.length() - 1)).append(")");
+ }
+
+ // clip off __.
+ if (this.importStatics && this.traversalScript.substring(0, 3).startsWith("__.")
+ && !NO_STATIC.stream().filter(name -> this.traversalScript.substring(3).startsWith(convertStepName(name))).findAny().isPresent()) {
+ this.traversalScript.delete(0, 3);
+ }
+ }
+
+ @Override
+ public PythonTranslator clone() {
+ try {
+ final PythonTranslator clone = (PythonTranslator) super.clone();
+ clone.traversalScript = new StringBuilder(this.traversalScript);
+ return clone;
+ } catch (final CloneNotSupportedException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.translatorString(this);
+ }
+
+ ///////
+
+ private String convertToString(final Object object) {
+ if (object instanceof String)
+ return "\"" + object + "\"";
+ else if (object instanceof List) {
+ final List<String> list = new ArrayList<>(((List) object).size());
+ for (final Object item : (List) object) {
+ list.add(convertToString(item));
+ }
+ return list.toString();
+ } else if (object instanceof Long)
+ return object + "L";
+ else if (object instanceof Boolean)
+ return object.equals(Boolean.TRUE) ? "True" : "False";
+ else if (object instanceof Class)
+ return ((Class) object).getCanonicalName();
+ else if (object instanceof VertexProperty.Cardinality)
+ return "Cardinality." + object.toString();
+ else if (object instanceof SackFunctions.Barrier)
+ return "Barrier." + object.toString();
+ else if (object instanceof Enum)
+ return convertStatic(((Enum) object).getDeclaringClass().getSimpleName() + ".") + convertStepName(object.toString());
+ else if (object instanceof P)
+ return convertPToString((P) object, new StringBuilder()).toString();
+ else if (object instanceof Element)
+ return convertToString(((Element) object).id()); // hack
+ else if (object instanceof Traversal)
+ return ((Traversal) object).asAdmin().getStrategies().getStrategy(TranslationStrategy.class).get().getTranslator().getTraversalScript();
+ else if (object instanceof Computer) {
+ return "";
+ } else if (object instanceof Lambda) {
+ final String lambdaString = ((Lambda) object).getLambdaScript();
+ return lambdaString.startsWith("lambda") ? lambdaString : "lambda: \"" + lambdaString + "\"";
+ } else
+ return null == object ? "" : object.toString();
+ }
+
+ private String convertStatic(final String name) {
+ return this.importStatics ? "" : name;
+ }
+
+ private String convertStepName(final String stepName) {
+ if (PREFIX_NAMES.contains(stepName))
+ return "_" + stepName;
+ else
+ return stepName;
+ }
+
+ private StringBuilder convertPToString(final P p, final StringBuilder current) {
+ if (p instanceof ConnectiveP) {
+ final List<P<?>> list = ((ConnectiveP) p).getPredicates();
+ for (int i = 0; i < list.size(); i++) {
+ convertPToString(list.get(i), current);
+ if (i < list.size() - 1)
+ current.append(p instanceof OrP ? "._or(" : "._and(");
+ }
+ current.append(")");
+ } else
+ current.append(convertStatic("P.")).append(p.getBiPredicate().toString()).append("(").append(convertToString(p.getValue())).append(")");
+ return current;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
new file mode 100644
index 0000000..53dec75
--- /dev/null
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.python;
+
+public class GenerateGremlinPython {
+ public static void main(String[] args) {
+ String dest;
+ if (args.length > 0) {
+ dest = args[0];
+ } else {
+ System.out.println("Usage: java GenerateGremlinPython <path/to/dest>");
+ return;
+ }
+ GremlinPythonSourceGenerator.create(dest);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
new file mode 100644
index 0000000..090fa5c
--- /dev/null
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.python.jsr223;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.python.jsr223.PyScriptEngine;
+import org.python.jsr223.PyScriptEngineFactory;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptException;
+import java.io.Reader;
+import java.util.Arrays;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GremlinJythonScriptEngine implements ScriptEngine {
+
+ private final PyScriptEngine pyScriptEngine;
+
+ public GremlinJythonScriptEngine() {
+ this.pyScriptEngine = (PyScriptEngine) new PyScriptEngineFactory().getScriptEngine();
+ try {
+ // Groovy's AbstractImportCustomizer should pull from a common source
+ for (final Class x : Arrays.asList(Graph.class, GraphTraversal.class, GraphTraversalSource.class)) {
+ this.pyScriptEngine.eval("from " + x.getPackage().getName() + " import " + x.getSimpleName());
+ }
+ } catch (final ScriptException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+
+ }
+
+
+ @Override
+ public Object eval(String script, ScriptContext context) throws ScriptException {
+ return this.pyScriptEngine.eval(script, context);
+ }
+
+ @Override
+ public Object eval(Reader reader, ScriptContext context) throws ScriptException {
+ return this.pyScriptEngine.eval(reader, context);
+ }
+
+ @Override
+ public Object eval(String script) throws ScriptException {
+ return this.pyScriptEngine.eval(script);
+ }
+
+ @Override
+ public Object eval(Reader reader) throws ScriptException {
+ return this.pyScriptEngine.eval(reader);
+ }
+
+ @Override
+ public Object eval(String script, Bindings n) throws ScriptException {
+ return this.pyScriptEngine.eval(script, n);
+ }
+
+ @Override
+ public Object eval(Reader reader, Bindings n) throws ScriptException {
+ return this.pyScriptEngine.eval(reader, n);
+ }
+
+ @Override
+ public void put(String key, Object value) {
+ this.pyScriptEngine.put(key, value);
+ }
+
+ @Override
+ public Object get(String key) {
+ return this.pyScriptEngine.get(key);
+ }
+
+ @Override
+ public Bindings getBindings(int scope) {
+ return this.pyScriptEngine.getBindings(scope);
+ }
+
+ @Override
+ public void setBindings(Bindings bindings, int scope) {
+ this.pyScriptEngine.setBindings(bindings, scope);
+ }
+
+ @Override
+ public Bindings createBindings() {
+ return this.pyScriptEngine.createBindings();
+ }
+
+ @Override
+ public ScriptContext getContext() {
+ return this.pyScriptEngine.getContext();
+ }
+
+ @Override
+ public void setContext(ScriptContext context) {
+ this.pyScriptEngine.setContext(context);
+ }
+
+ @Override
+ public ScriptEngineFactory getFactory() {
+ return new GremlinJythonScriptEngineFactory();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
new file mode 100644
index 0000000..81256ea
--- /dev/null
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.python.jsr223;
+
+import org.apache.tinkerpop.gremlin.util.Gremlin;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GremlinJythonScriptEngineFactory implements ScriptEngineFactory {
+
+ private static final String ENGINE_NAME = "gremlin-jython";
+ private static final String LANGUAGE_NAME = "gremlin-jython";
+ private static final String PLAIN = "plain";
+ private static final List<String> EXTENSIONS = Arrays.asList("py");
+
+ @Override
+ public String getEngineName() {
+ return ENGINE_NAME;
+ }
+
+ @Override
+ public String getEngineVersion() {
+ return Gremlin.version();
+ }
+
+ @Override
+ public List<String> getExtensions() {
+ return EXTENSIONS;
+ }
+
+ @Override
+ public String getLanguageName() {
+ return LANGUAGE_NAME;
+ }
+
+ @Override
+ public String getLanguageVersion() {
+ return Gremlin.version();
+ }
+
+ @Override
+ public String getMethodCallSyntax(final String obj, final String m, final String... args) {
+ return null;
+ }
+
+ @Override
+ public List<String> getMimeTypes() {
+ return Arrays.asList(PLAIN);
+ }
+
+ @Override
+ public List<String> getNames() {
+ return Arrays.asList(LANGUAGE_NAME);
+ }
+
+ @Override
+ public String getOutputStatement(final String toDisplay) {
+ return "println " + toDisplay;
+ }
+
+ @Override
+ public Object getParameter(final String key) {
+ if (key.equals(ScriptEngine.ENGINE)) {
+ return this.getEngineName();
+ } else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
+ return this.getEngineVersion();
+ } else if (key.equals(ScriptEngine.NAME)) {
+ return ENGINE_NAME;
+ } else if (key.equals(ScriptEngine.LANGUAGE)) {
+ return this.getLanguageName();
+ } else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
+ return this.getLanguageVersion();
+ } else
+ return null;
+ }
+
+ @Override
+ public String getProgram(final String... statements) {
+ String program = "";
+
+ for (String statement : statements) {
+ program = program + statement + "\n";
+ }
+
+ return program;
+ }
+
+ @Override
+ public ScriptEngine getScriptEngine() {
+ return new GremlinJythonScriptEngine();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/LICENSE
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/LICENSE b/gremlin-python/src/main/jython/LICENSE
new file mode 100644
index 0000000..7a4a3ea
--- /dev/null
+++ b/gremlin-python/src/main/jython/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/MANIFEST.in
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/MANIFEST.in b/gremlin-python/src/main/jython/MANIFEST.in
new file mode 100644
index 0000000..c7cc6dc
--- /dev/null
+++ b/gremlin-python/src/main/jython/MANIFEST.in
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+include LICENSE
+include NOTICE
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/NOTICE
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/NOTICE b/gremlin-python/src/main/jython/NOTICE
new file mode 100644
index 0000000..90e77a8
--- /dev/null
+++ b/gremlin-python/src/main/jython/NOTICE
@@ -0,0 +1,5 @@
+Apache TinkerPop
+Copyright 2015-2016 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file