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:18 UTC
[1/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.
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1278 2fb26e46c -> 496745397
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java
deleted file mode 100644
index 57f94ca..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java
+++ /dev/null
@@ -1,33 +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.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessComputerSuite.class)
-@GraphProviderClass(provider = GroovyComputerProvider.class, graph = TinkerGraph.class)
-public class GroovyProcessComputerTest {
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java
deleted file mode 100644
index a8252d1..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java
+++ /dev/null
@@ -1,33 +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.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessStandardSuite.class)
-@GraphProviderClass(provider = GroovyProvider.class, graph = TinkerGraph.class)
-public class GroovyProcessStandardTest {
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java
deleted file mode 100644
index fd7c6a9..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java
+++ /dev/null
@@ -1,39 +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.VariantGraphProvider;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class GroovyProvider extends VariantGraphProvider {
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- if ((Boolean) graph.configuration().getProperty("skipTest"))
- return graph.traversal();
- //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance());
- else
- return graph.traversal().withTranslator(GroovyTranslator.of("g"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
deleted file mode 100644
index 608b40f..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
+++ /dev/null
@@ -1,46 +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.python;
-
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class JythonScriptEngineSetup {
-
- private JythonScriptEngineSetup() {
- }
-
- public static void setup() {
- try {
- final ScriptEngine jythonEngine = ScriptEngineCache.get("jython");
- jythonEngine.eval("from gremlin_python.gremlin_python import *");
- jythonEngine.eval("from gremlin_python.gremlin_python import __");
- jythonEngine.eval("from gremlin_python.groovy_translator import GroovyTranslator");
- jythonEngine.eval("from gremlin_rest_driver import RESTRemoteConnection");
- } catch (final ScriptException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonBypassTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonBypassTranslator.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonBypassTranslator.java
deleted file mode 100644
index 71ef97f..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonBypassTranslator.java
+++ /dev/null
@@ -1,88 +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.python;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.util.Translator;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-class PythonBypassTranslator extends PythonTranslator {
-
- private PythonBypassTranslator(final String alias, final boolean importStatics) {
- super(alias, importStatics);
- }
-
- public static PythonBypassTranslator of(final String alias) {
- return new PythonBypassTranslator(alias, false);
- }
-
- public static PythonBypassTranslator of(final String alias, final boolean importStatics) {
- return new PythonBypassTranslator(alias, importStatics);
- }
-
- @Override
- public void addStep(final Traversal.Admin<?, ?> traversal, final String stepName, final Object... arguments) {
- super.addStep(traversal, stepName, arguments);
- if (!this.importStatics)
- assert this.traversalScript.toString().startsWith(this.alias + ".");
- }
-
- @Override
- public Translator getAnonymousTraversalTranslator() {
- return new PythonBypassTranslator("__", this.importStatics);
- }
-
- @Override
- public String getTargetLanguage() {
- return "gremlin-groovy";
- }
-
- @Override
- public String getTraversalScript() {
- final String traversal = super.getTraversalScript();
- if (!this.alias.equals("__")) {
- try {
- final ScriptEngine jythonEngine = ScriptEngineCache.get("jython");
- final Bindings jythonBindings = new SimpleBindings();
- jythonBindings.put(this.alias, jythonEngine.eval("PythonGraphTraversalSource(GroovyTranslator(\"" + this.alias + "\"))"));
- jythonEngine.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
- return jythonEngine.eval(traversal).toString();
- } catch (final ScriptException e) {
- throw new IllegalArgumentException(e.getMessage(), e);
- }
- } else
- return traversal;
- }
-
- @Override
- public String toString() {
- return StringFactory.translatorString(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java
deleted file mode 100644
index 70bbf4f..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java
+++ /dev/null
@@ -1,37 +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.python;
-
-import org.apache.tinkerpop.gremlin.GraphProvider;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
-public class PythonComputerProvider extends PythonProvider {
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- return super.traversal(graph).withComputer();
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java
deleted file mode 100644
index 5f79f9a..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java
+++ /dev/null
@@ -1,34 +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.python;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessComputerSuite.class)
-@GraphProviderClass(provider = PythonComputerProvider.class, graph = TinkerGraph.class)
-public class PythonProcessComputerTest {
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java
deleted file mode 100644
index a170408..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java
+++ /dev/null
@@ -1,34 +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.python;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessStandardSuite.class)
-@GraphProviderClass(provider = PythonProvider.class, graph = TinkerGraph.class)
-public class PythonProcessStandardTest {
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
deleted file mode 100644
index 10b9bdc..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
+++ /dev/null
@@ -1,61 +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.python;
-
-import org.apache.tinkerpop.gremlin.VariantGraphProvider;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import java.io.File;
-import java.util.Random;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class PythonProvider extends VariantGraphProvider {
-
- private static final boolean IMPORT_STATICS = new Random().nextBoolean();
-
- static {
- JythonScriptEngineSetup.setup();
- }
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- if ((Boolean) graph.configuration().getProperty("skipTest"))
- return graph.traversal();
- //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance());
- else {
- try {
- if (IMPORT_STATICS)
- ScriptEngineCache.get("jython").eval("for k in statics:\n globals()[k] = statics[k]");
- else
- ScriptEngineCache.get("jython").eval("for k in statics:\n if k in globals():\n del globals()[k]");
- } catch (final ScriptException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- return graph.traversal().withTranslator(PythonBypassTranslator.of("g", IMPORT_STATICS)); // the bypass translator will ensure that gremlin-groovy is ultimately used
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonTranslatorTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonTranslatorTest.java
deleted file mode 100644
index 3ebda0c..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonTranslatorTest.java
+++ /dev/null
@@ -1,92 +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.python;
-
-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;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.creation.TranslationStrategy;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.apache.tinkerpop.gremlin.util.function.Lambda;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class PythonTranslatorTest {
-
- static {
- JythonScriptEngineSetup.setup();
- }
-
- @Test
- public void shouldSupportStringSupplierLambdas() throws Exception {
- final GraphTraversalSource g = TinkerFactory.createModern().traversal().withTranslator(PythonBypassTranslator.of("g",true));
- GraphTraversal.Admin<Vertex, Integer> t = g.withSideEffect("lengthSum", 0).withSack(1)
- .V()
- .filter(Lambda.predicate("lambda: \"it.get().label().equals('person')\""))
- .flatMap(Lambda.<Traverser<Vertex>, Iterator<Vertex>>function("it.get().vertices(Direction.OUT)"))
- .map(Lambda.<Traverser<Vertex>, Integer>function("it.get().value('name').length()"))
- .sideEffect(Lambda.consumer("x -> x.sideEffects('lengthSum', x.<Integer>sideEffects('lengthSum') + x.get())"))
- .order().by(Lambda.comparator("a,b -> a <=> b"))
- .sack(Lambda.biFunction("lambda : \"a,b -> a + b\""))
- .asAdmin();
- final List<Integer> sacks = new ArrayList<>();
- final List<Integer> lengths = new ArrayList<>();
- while (t.hasNext()) {
- final Traverser.Admin<Integer> traverser = t.getEndStep().next();
- sacks.add(traverser.sack());
- lengths.add(traverser.get());
- }
- assertFalse(t.hasNext());
- //
- assertEquals(6, lengths.size());
- assertEquals(3, lengths.get(0).intValue());
- assertEquals(3, lengths.get(1).intValue());
- assertEquals(3, lengths.get(2).intValue());
- assertEquals(4, lengths.get(3).intValue());
- assertEquals(5, lengths.get(4).intValue());
- assertEquals(6, lengths.get(5).intValue());
- ///
- assertEquals(6, sacks.size());
- assertEquals(4, sacks.get(0).intValue());
- assertEquals(4, sacks.get(1).intValue());
- assertEquals(4, sacks.get(2).intValue());
- assertEquals(5, sacks.get(3).intValue());
- assertEquals(6, sacks.get(4).intValue());
- assertEquals(7, sacks.get(5).intValue());
- //
- assertEquals(24, t.getSideEffects().<Number>get("lengthSum").intValue());
- }
-
- @Test
- public void shouldHaveValidToString() {
- assertEquals("translator[h:gremlin-java->jython]", PythonTranslator.of("h").toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
deleted file mode 100644
index 8d9b185..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
+++ /dev/null
@@ -1,67 +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.python.driver;
-
-import org.apache.tinkerpop.gremlin.VariantGraphProvider;
-import org.apache.tinkerpop.gremlin.python.JythonScriptEngineSetup;
-import org.apache.tinkerpop.gremlin.server.GremlinServer;
-import org.apache.tinkerpop.gremlin.server.Settings;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.SimpleBindings;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class RESTRemoteConnectionTest {
-
- private final ScriptEngine jython = ScriptEngineCache.get("jython");
-
- @Before
- public void setup() {
- try {
- JythonScriptEngineSetup.setup();
- final Bindings jythonBindings = new SimpleBindings();
- jythonBindings.put("g", jython.eval("PythonGraphTraversalSource(GroovyTranslator('g'), RESTRemoteConnection('http://localhost:8182'))"));
- jython.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
- final GremlinServer server = new GremlinServer(Settings.read(VariantGraphProvider.class.getResourceAsStream("gremlin-server-rest-modern.yaml")));
- server.start().join();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void testRESTRemoteConnection() throws Exception {
- final List<String> results = (List) jython.eval("g.V().repeat(__.out()).times(2).name.toList()");
- assertEquals(2, results.size());
- assertTrue(results.contains("lop"));
- assertTrue(results.contains("ripple"));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
deleted file mode 100644
index 7582877..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
+++ /dev/null
@@ -1,50 +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.python.jsr223;
-
-import org.junit.Test;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class GremlinJythonScriptEngineTest {
-
- @Test
- public void shouldGetEngineByName() throws Exception {
- final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
- assertNotNull(engine);
- assertTrue(engine instanceof GremlinJythonScriptEngine);
- assertTrue(engine.eval("Graph") instanceof Class);
- assertEquals(3, engine.eval("1+2"));
- }
-
- @Test
- public void shouldHaveStandardImports() throws Exception {
- final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
- assertTrue(engine.eval("Graph") instanceof Class);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory b/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
deleted file mode 100644
index 910facc..0000000
--- a/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
+++ /dev/null
@@ -1,2 +0,0 @@
-org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory
-org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngineFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/resources/log4j-silent.properties
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/log4j-silent.properties b/gremlin-variant/src/test/resources/log4j-silent.properties
deleted file mode 100644
index 1825bb0..0000000
--- a/gremlin-variant/src/test/resources/log4j-silent.properties
+++ /dev/null
@@ -1,23 +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.
-
-# this file should always have logging set to OFF. it seems, however, that an appender of some sort is
-# required or else some logs throw error and use other log4j.properties files on the path.
-log4j.rootLogger=OFF, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/log4j-test.properties b/gremlin-variant/src/test/resources/log4j-test.properties
deleted file mode 100644
index 79038b1..0000000
--- a/gremlin-variant/src/test/resources/log4j-test.properties
+++ /dev/null
@@ -1,23 +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.
-#
-
-log4j.rootLogger=WARN, stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/resources/org/apache/tinkerpop/gremlin/gremlin-server-rest-modern.yaml
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/org/apache/tinkerpop/gremlin/gremlin-server-rest-modern.yaml b/gremlin-variant/src/test/resources/org/apache/tinkerpop/gremlin/gremlin-server-rest-modern.yaml
deleted file mode 100644
index 3a54a0c..0000000
--- a/gremlin-variant/src/test/resources/org/apache/tinkerpop/gremlin/gremlin-server-rest-modern.yaml
+++ /dev/null
@@ -1,45 +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.
-
-host: localhost
-port: 8182
-threadPoolWorker: 1
-gremlinPool: 8
-scriptEvaluationTimeout: 30000
-channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
-graphs: {
- graph: ../gremlin-server/conf/tinkergraph-empty.properties}
-plugins:
- - tinkerpop.tinkergraph
-scriptEngines: {
- gremlin-groovy: {
- imports: [java.lang.Math],
- staticImports: [java.lang.Math.PI],
- scripts: [../gremlin-server/scripts/generate-modern.groovy]}}
-serializers:
- - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
- - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/json
-metrics: {
- slf4jReporter: {enabled: true, interval: 180000}}
-strictTransactionManagement: false
-threadPoolBoss: 1
-maxInitialLineLength: 4096
-maxHeaderSize: 8192
-maxChunkSize: 8192
-maxContentLength: 65536
-maxAccumulationBufferComponents: 1024
-resultIterationBatchSize: 64
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1d14934..dc1bcfe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,7 +117,7 @@ limitations under the License.
<module>gremlin-groovy</module>
<module>gremlin-groovy-test</module>
<module>tinkergraph-gremlin</module>
- <module>gremlin-variant</module>
+ <module>gremlin-python</module>
<module>hadoop-gremlin</module>
<module>spark-gremlin</module>
<module>giraph-gremlin</module>
@@ -338,7 +338,8 @@ limitations under the License.
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
- <argLine>-Dlog4j.configuration=${log4j-test.properties} -Dbuild.dir=${project.build.directory} -Dis.testing=true
+ <argLine>-Dlog4j.configuration=${log4j-test.properties} -Dbuild.dir=${project.build.directory}
+ -Dis.testing=true
</argLine>
<excludes>
<exclude>**/*IntegrateTest.java</exclude>
@@ -364,7 +365,7 @@ limitations under the License.
<argLine>-Dlog4j.configuration=${log4j-test.properties} -Dhost=localhost -Dport=8182
-Djub.consumers=CONSOLE,H2 -Djub.db.file=target/performance/h2/benchmarks
-Djub.charts.dir=target/performance/charts -Djub.customkey=${project.parent.version}
- -Dbuild.dir=${project.build.directory} -Dis.testing=true
+ -Dbuild.dir=${project.build.directory} -Dis.testing=true
</argLine>
<summaryFile>target/failsafe-reports/failsafe-integration.xml</summaryFile>
</configuration>
@@ -822,7 +823,8 @@ limitations under the License.
<configuration>
<sourceDirectory>${asciidoc.input.dir}/tutorials/getting-started</sourceDirectory>
<sourceDocumentName>index.asciidoc</sourceDocumentName>
- <outputDirectory>${htmlsingle.output.dir}/tutorials/getting-started</outputDirectory>
+ <outputDirectory>${htmlsingle.output.dir}/tutorials/getting-started
+ </outputDirectory>
<backend>html5</backend>
<doctype>article</doctype>
<attributes>
@@ -842,9 +844,11 @@ limitations under the License.
<goal>process-asciidoc</goal>
</goals>
<configuration>
- <sourceDirectory>${asciidoc.input.dir}/tutorials/the-gremlin-console</sourceDirectory>
+ <sourceDirectory>${asciidoc.input.dir}/tutorials/the-gremlin-console
+ </sourceDirectory>
<sourceDocumentName>index.asciidoc</sourceDocumentName>
- <outputDirectory>${htmlsingle.output.dir}/tutorials/the-gremlin-console</outputDirectory>
+ <outputDirectory>${htmlsingle.output.dir}/tutorials/the-gremlin-console
+ </outputDirectory>
<backend>html5</backend>
<doctype>article</doctype>
<attributes>
@@ -864,9 +868,11 @@ limitations under the License.
<goal>process-asciidoc</goal>
</goals>
<configuration>
- <sourceDirectory>${asciidoc.input.dir}/tutorials/gremlin-language-variants</sourceDirectory>
+ <sourceDirectory>${asciidoc.input.dir}/tutorials/gremlin-language-variants
+ </sourceDirectory>
<sourceDocumentName>index.asciidoc</sourceDocumentName>
- <outputDirectory>${htmlsingle.output.dir}/tutorials/gremlin-language-variants</outputDirectory>
+ <outputDirectory>${htmlsingle.output.dir}/tutorials/gremlin-language-variants
+ </outputDirectory>
<backend>html5</backend>
<doctype>article</doctype>
<attributes>
@@ -1059,7 +1065,8 @@ limitations under the License.
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
- <argLine>-Dlog4j.configuration=${log4j-silent.properties} -Dbuild.dir=${project.build.directory} -Dis.testing=true
+ <argLine>-Dlog4j.configuration=${log4j-silent.properties}
+ -Dbuild.dir=${project.build.directory} -Dis.testing=true
</argLine>
<excludes>
<exclude>**/*IntegrateTest.java</exclude>
@@ -1107,7 +1114,7 @@ limitations under the License.
<activation>
<activeByDefault>false</activeByDefault>
<os>
- <family>windows</family>
+ <family>windows</family>
</os>
</activation>
<build>
@@ -1135,7 +1142,10 @@ limitations under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Dlog4j.configuration=${log4j-test.properties} -Dbuild.dir=${project.build.directory} -Dhadoop.home.dir=${project.build.directory}/hadoop_home -Dis.testing=true</argLine>
+ <argLine>-Dlog4j.configuration=${log4j-test.properties}
+ -Dbuild.dir=${project.build.directory}
+ -Dhadoop.home.dir=${project.build.directory}/hadoop_home -Dis.testing=true
+ </argLine>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorComputerProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorComputerProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorComputerProvider.java
new file mode 100644
index 0000000..fb844e2
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorComputerProvider.java
@@ -0,0 +1,37 @@
+/*
+ * 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.GraphProvider;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
+public class TinkerGraphGroovyTranslatorComputerProvider extends TinkerGraphGroovyTranslatorProvider {
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ return super.traversal(graph).withComputer();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessComputerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessComputerTest.java
new file mode 100644
index 0000000..6ef75c0
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessComputerTest.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.java.translator;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessComputerSuite.class)
+@GraphProviderClass(provider = TinkerGraphGroovyTranslatorComputerProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphGroovyTranslatorProcessComputerTest {
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessStandardTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessStandardTest.java
new file mode 100644
index 0000000..d37992f
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProcessStandardTest.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.java.translator;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessStandardSuite.class)
+@GraphProviderClass(provider = TinkerGraphGroovyTranslatorProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphGroovyTranslatorProcessStandardTest {
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProvider.java
new file mode 100644
index 0000000..6ca1805
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphGroovyTranslatorProvider.java
@@ -0,0 +1,75 @@
+/*
+ * 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.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider {
+
+ private static Set<String> SKIP_TESTS = new HashSet<>(Arrays.asList(
+ "testProfileStrategyCallback",
+ "testProfileStrategyCallbackSideEffect",
+ "g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX",
+ "g_V_both_hasLabelXpersonX_order_byXage_decrX_name",
+ "g_VX1X_out_injectXv2X_name",
+ "shouldSupportGraphFilter",
+ "shouldNeverPropagateANoBulkTraverser",
+ "shouldNeverPropagateANullValuedTraverser",
+ "shouldTraversalResetProperly",
+ "shouldHidePartitionKeyForValues",
+ ProgramTest.Traversals.class.getCanonicalName(),
+ TraversalInterruptionTest.class.getCanonicalName(),
+ TraversalInterruptionComputerTest.class.getCanonicalName(),
+ ElementIdStrategyProcessTest.class.getCanonicalName()));
+
+
+ @Override
+ public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName,
+ final LoadGraphWith.GraphData loadGraphWith) {
+
+ final Map<String, Object> config = super.getBaseConfiguration(graphName, test, testMethodName, loadGraphWith);
+ config.put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName()));
+ return config;
+ }
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ if ((Boolean) graph.configuration().getProperty("skipTest"))
+ return graph.traversal();
+ //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance());
+ else
+ return graph.traversal().withTranslator(GroovyTranslator.of("g"));
+ }
+}
\ No newline at end of file
[5/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.
Posted by ok...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/README
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/README b/gremlin-python/src/main/jython/README
new file mode 100644
index 0000000..e7ad5fb
--- /dev/null
+++ b/gremlin-python/src/main/jython/README
@@ -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.
+
+Apache TinkerPop - Gremlin Python - Gremlin Language Variant
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_driver/__init__.py b/gremlin-python/src/main/jython/gremlin_driver/__init__.py
new file mode 100644
index 0000000..dcbd144
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_driver/__init__.py
@@ -0,0 +1,22 @@
+'''
+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.
+'''
+from gremlin_driver import RemoteConnection
+from gremlin_driver import Traverser
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_driver/gremlin_driver.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_driver/gremlin_driver.py b/gremlin-python/src/main/jython/gremlin_driver/gremlin_driver.py
new file mode 100644
index 0000000..96939d4
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_driver/gremlin_driver.py
@@ -0,0 +1,39 @@
+'''
+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.
+'''
+from abc import abstractmethod
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+
+class Traverser(object):
+ def __init__(self, object, bulk):
+ self.object = object
+ self.bulk = bulk
+ def __repr__(self):
+ return str(self.object)
+
+
+class RemoteConnection(object):
+ def __init__(self, url):
+ self.url = url
+
+ @abstractmethod
+ def submit(self, target_language, script, bindings):
+ print "sending " + script + " to GremlinServer..."
+ return iter([])
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_python/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/__init__.py b/gremlin-python/src/main/jython/gremlin_python/__init__.py
new file mode 100644
index 0000000..e9e2fa5
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/__init__.py
@@ -0,0 +1,35 @@
+'''
+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.
+'''
+from gremlin_python import PythonGraphTraversal
+from gremlin_python import PythonGraphTraversalSource
+from gremlin_python import __
+from gremlin_python import statics
+from gremlin_python import T
+from gremlin_python import Order
+from gremlin_python import Cardinality
+from gremlin_python import Column
+from gremlin_python import Direction
+from gremlin_python import Operator
+from gremlin_python import P
+from gremlin_python import Pop
+from gremlin_python import Scope
+from gremlin_python import Barrier
+from groovy_translator import GroovyTranslator
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_python/gremlin_python.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/gremlin_python.py b/gremlin-python/src/main/jython/gremlin_python/gremlin_python.py
new file mode 100644
index 0000000..ab478d0
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/gremlin_python.py
@@ -0,0 +1,1832 @@
+'''
+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.
+'''
+from collections import OrderedDict
+from aenum import Enum
+statics = OrderedDict()
+
+
+globalTranslator = None
+
+
+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 + "]"
+ def E(self, *args):
+ traversal = PythonGraphTraversal(self.translator, self.remote_connection)
+ traversal.translator.addSpawnStep(traversal, "E", *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
+ def V(self, *args):
+ traversal = PythonGraphTraversal(self.translator, self.remote_connection)
+ traversal.translator.addSpawnStep(traversal, "V", *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
+ def addV(self, *args):
+ traversal = PythonGraphTraversal(self.translator, self.remote_connection)
+ traversal.translator.addSpawnStep(traversal, "addV", *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
+ def inject(self, *args):
+ traversal = PythonGraphTraversal(self.translator, self.remote_connection)
+ traversal.translator.addSpawnStep(traversal, "inject", *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
+ def withBulk(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withBulk", *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
+ def withComputer(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withComputer", *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
+ def withPath(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withPath", *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
+ def withSack(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withSack", *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
+ def withSideEffect(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withSideEffect", *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
+ def withStrategies(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withStrategies", *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
+ def withTranslator(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withTranslator", *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
+ def withoutStrategies(self, *args):
+ source = PythonGraphTraversalSource(self.translator, self.remote_connection)
+ source.translator.addSource(source, "withoutStrategies", *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
+
+
+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
+ def V(self, *args):
+ self.translator.addStep(self, "V", *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
+ def _and(self, *args):
+ self.translator.addStep(self, "_and", *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
+ def _as(self, *args):
+ self.translator.addStep(self, "_as", *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
+ def _from(self, *args):
+ self.translator.addStep(self, "_from", *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
+ def _in(self, *args):
+ self.translator.addStep(self, "_in", *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
+ def _is(self, *args):
+ self.translator.addStep(self, "_is", *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
+ def _not(self, *args):
+ self.translator.addStep(self, "_not", *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
+ def _or(self, *args):
+ self.translator.addStep(self, "_or", *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
+ def addE(self, *args):
+ self.translator.addStep(self, "addE", *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
+ def addInE(self, *args):
+ self.translator.addStep(self, "addInE", *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
+ def addOutE(self, *args):
+ self.translator.addStep(self, "addOutE", *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
+ def addV(self, *args):
+ self.translator.addStep(self, "addV", *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
+ def aggregate(self, *args):
+ self.translator.addStep(self, "aggregate", *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
+ def asAdmin(self, *args):
+ self.translator.addStep(self, "asAdmin", *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
+ def barrier(self, *args):
+ self.translator.addStep(self, "barrier", *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
+ def both(self, *args):
+ self.translator.addStep(self, "both", *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
+ def bothE(self, *args):
+ self.translator.addStep(self, "bothE", *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
+ def bothV(self, *args):
+ self.translator.addStep(self, "bothV", *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
+ def branch(self, *args):
+ self.translator.addStep(self, "branch", *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
+ def by(self, *args):
+ self.translator.addStep(self, "by", *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
+ def cap(self, *args):
+ self.translator.addStep(self, "cap", *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
+ def choose(self, *args):
+ self.translator.addStep(self, "choose", *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
+ def coalesce(self, *args):
+ self.translator.addStep(self, "coalesce", *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
+ def coin(self, *args):
+ self.translator.addStep(self, "coin", *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
+ def constant(self, *args):
+ self.translator.addStep(self, "constant", *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
+ def count(self, *args):
+ self.translator.addStep(self, "count", *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
+ def cyclicPath(self, *args):
+ self.translator.addStep(self, "cyclicPath", *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
+ def dedup(self, *args):
+ self.translator.addStep(self, "dedup", *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
+ def drop(self, *args):
+ self.translator.addStep(self, "drop", *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
+ def emit(self, *args):
+ self.translator.addStep(self, "emit", *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
+ def filter(self, *args):
+ self.translator.addStep(self, "filter", *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
+ def flatMap(self, *args):
+ self.translator.addStep(self, "flatMap", *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
+ def fold(self, *args):
+ self.translator.addStep(self, "fold", *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
+ def group(self, *args):
+ self.translator.addStep(self, "group", *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
+ def groupCount(self, *args):
+ self.translator.addStep(self, "groupCount", *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
+ def groupV3d0(self, *args):
+ self.translator.addStep(self, "groupV3d0", *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
+ def has(self, *args):
+ self.translator.addStep(self, "has", *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
+ def hasId(self, *args):
+ self.translator.addStep(self, "hasId", *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
+ def hasKey(self, *args):
+ self.translator.addStep(self, "hasKey", *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
+ def hasLabel(self, *args):
+ self.translator.addStep(self, "hasLabel", *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
+ def hasNot(self, *args):
+ self.translator.addStep(self, "hasNot", *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
+ def hasValue(self, *args):
+ self.translator.addStep(self, "hasValue", *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
+ def id(self, *args):
+ self.translator.addStep(self, "id", *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
+ def identity(self, *args):
+ self.translator.addStep(self, "identity", *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
+ def inE(self, *args):
+ self.translator.addStep(self, "inE", *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
+ def inV(self, *args):
+ self.translator.addStep(self, "inV", *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
+ def inject(self, *args):
+ self.translator.addStep(self, "inject", *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
+ def iterate(self, *args):
+ self.translator.addStep(self, "iterate", *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
+ def key(self, *args):
+ self.translator.addStep(self, "key", *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
+ def label(self, *args):
+ self.translator.addStep(self, "label", *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
+ def limit(self, *args):
+ self.translator.addStep(self, "limit", *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
+ def local(self, *args):
+ self.translator.addStep(self, "local", *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
+ def loops(self, *args):
+ self.translator.addStep(self, "loops", *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
+ def map(self, *args):
+ self.translator.addStep(self, "map", *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
+ def mapKeys(self, *args):
+ self.translator.addStep(self, "mapKeys", *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
+ def mapValues(self, *args):
+ self.translator.addStep(self, "mapValues", *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
+ def match(self, *args):
+ self.translator.addStep(self, "match", *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
+ def max(self, *args):
+ self.translator.addStep(self, "max", *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
+ def mean(self, *args):
+ self.translator.addStep(self, "mean", *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
+ def min(self, *args):
+ self.translator.addStep(self, "min", *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
+ def option(self, *args):
+ self.translator.addStep(self, "option", *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
+ def optional(self, *args):
+ self.translator.addStep(self, "optional", *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
+ def order(self, *args):
+ self.translator.addStep(self, "order", *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
+ def otherV(self, *args):
+ self.translator.addStep(self, "otherV", *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
+ def out(self, *args):
+ self.translator.addStep(self, "out", *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
+ def outE(self, *args):
+ self.translator.addStep(self, "outE", *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
+ def outV(self, *args):
+ self.translator.addStep(self, "outV", *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
+ def pageRank(self, *args):
+ self.translator.addStep(self, "pageRank", *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
+ def path(self, *args):
+ self.translator.addStep(self, "path", *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
+ def peerPressure(self, *args):
+ self.translator.addStep(self, "peerPressure", *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
+ def profile(self, *args):
+ self.translator.addStep(self, "profile", *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
+ def program(self, *args):
+ self.translator.addStep(self, "program", *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
+ def project(self, *args):
+ self.translator.addStep(self, "project", *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
+ def properties(self, *args):
+ self.translator.addStep(self, "properties", *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
+ def property(self, *args):
+ self.translator.addStep(self, "property", *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
+ def propertyMap(self, *args):
+ self.translator.addStep(self, "propertyMap", *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
+ def range(self, *args):
+ self.translator.addStep(self, "range", *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
+ def repeat(self, *args):
+ self.translator.addStep(self, "repeat", *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
+ def sack(self, *args):
+ self.translator.addStep(self, "sack", *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
+ def sample(self, *args):
+ self.translator.addStep(self, "sample", *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
+ def select(self, *args):
+ self.translator.addStep(self, "select", *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
+ def sideEffect(self, *args):
+ self.translator.addStep(self, "sideEffect", *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
+ def simplePath(self, *args):
+ self.translator.addStep(self, "simplePath", *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
+ def store(self, *args):
+ self.translator.addStep(self, "store", *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
+ def subgraph(self, *args):
+ self.translator.addStep(self, "subgraph", *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
+ def sum(self, *args):
+ self.translator.addStep(self, "sum", *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
+ def tail(self, *args):
+ self.translator.addStep(self, "tail", *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
+ def timeLimit(self, *args):
+ self.translator.addStep(self, "timeLimit", *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
+ def times(self, *args):
+ self.translator.addStep(self, "times", *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
+ def to(self, *args):
+ self.translator.addStep(self, "to", *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
+ def toE(self, *args):
+ self.translator.addStep(self, "toE", *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
+ def toV(self, *args):
+ self.translator.addStep(self, "toV", *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
+ def tree(self, *args):
+ self.translator.addStep(self, "tree", *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
+ def unfold(self, *args):
+ self.translator.addStep(self, "unfold", *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
+ def union(self, *args):
+ self.translator.addStep(self, "union", *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
+ def until(self, *args):
+ self.translator.addStep(self, "until", *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
+ def value(self, *args):
+ self.translator.addStep(self, "value", *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
+ def valueMap(self, *args):
+ self.translator.addStep(self, "valueMap", *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
+ def values(self, *args):
+ self.translator.addStep(self, "values", *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
+ def where(self, *args):
+ self.translator.addStep(self, "where", *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
+
+
+class __(object):
+ @staticmethod
+ def V(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).V(*args)
+ @staticmethod
+ def __(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).__(*args)
+ @staticmethod
+ def _and(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._and(*args)
+ @staticmethod
+ def _as(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._as(*args)
+ @staticmethod
+ def _in(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._in(*args)
+ @staticmethod
+ def _is(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._is(*args)
+ @staticmethod
+ def _not(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._not(*args)
+ @staticmethod
+ def _or(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._or(*args)
+ @staticmethod
+ def addE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addE(*args)
+ @staticmethod
+ def addInE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addInE(*args)
+ @staticmethod
+ def addOutE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addOutE(*args)
+ @staticmethod
+ def addV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addV(*args)
+ @staticmethod
+ def aggregate(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).aggregate(*args)
+ @staticmethod
+ def barrier(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).barrier(*args)
+ @staticmethod
+ def both(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).both(*args)
+ @staticmethod
+ def bothE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).bothE(*args)
+ @staticmethod
+ def bothV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).bothV(*args)
+ @staticmethod
+ def branch(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).branch(*args)
+ @staticmethod
+ def cap(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).cap(*args)
+ @staticmethod
+ def choose(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).choose(*args)
+ @staticmethod
+ def coalesce(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).coalesce(*args)
+ @staticmethod
+ def coin(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).coin(*args)
+ @staticmethod
+ def constant(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).constant(*args)
+ @staticmethod
+ def count(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).count(*args)
+ @staticmethod
+ def cyclicPath(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).cyclicPath(*args)
+ @staticmethod
+ def dedup(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).dedup(*args)
+ @staticmethod
+ def drop(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).drop(*args)
+ @staticmethod
+ def emit(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).emit(*args)
+ @staticmethod
+ def filter(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).filter(*args)
+ @staticmethod
+ def flatMap(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).flatMap(*args)
+ @staticmethod
+ def fold(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).fold(*args)
+ @staticmethod
+ def group(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).group(*args)
+ @staticmethod
+ def groupCount(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).groupCount(*args)
+ @staticmethod
+ def groupV3d0(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).groupV3d0(*args)
+ @staticmethod
+ def has(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).has(*args)
+ @staticmethod
+ def hasId(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasId(*args)
+ @staticmethod
+ def hasKey(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasKey(*args)
+ @staticmethod
+ def hasLabel(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasLabel(*args)
+ @staticmethod
+ def hasNot(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasNot(*args)
+ @staticmethod
+ def hasValue(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasValue(*args)
+ @staticmethod
+ def id(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).id(*args)
+ @staticmethod
+ def identity(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).identity(*args)
+ @staticmethod
+ def inE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inE(*args)
+ @staticmethod
+ def inV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inV(*args)
+ @staticmethod
+ def inject(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inject(*args)
+ @staticmethod
+ def key(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).key(*args)
+ @staticmethod
+ def label(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).label(*args)
+ @staticmethod
+ def limit(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).limit(*args)
+ @staticmethod
+ def local(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).local(*args)
+ @staticmethod
+ def loops(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).loops(*args)
+ @staticmethod
+ def map(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).map(*args)
+ @staticmethod
+ def mapKeys(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mapKeys(*args)
+ @staticmethod
+ def mapValues(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mapValues(*args)
+ @staticmethod
+ def match(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).match(*args)
+ @staticmethod
+ def max(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).max(*args)
+ @staticmethod
+ def mean(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mean(*args)
+ @staticmethod
+ def min(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).min(*args)
+ @staticmethod
+ def optional(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).optional(*args)
+ @staticmethod
+ def order(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).order(*args)
+ @staticmethod
+ def otherV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).otherV(*args)
+ @staticmethod
+ def out(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).out(*args)
+ @staticmethod
+ def outE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).outE(*args)
+ @staticmethod
+ def outV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).outV(*args)
+ @staticmethod
+ def path(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).path(*args)
+ @staticmethod
+ def project(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).project(*args)
+ @staticmethod
+ def properties(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).properties(*args)
+ @staticmethod
+ def property(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).property(*args)
+ @staticmethod
+ def propertyMap(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).propertyMap(*args)
+ @staticmethod
+ def range(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).range(*args)
+ @staticmethod
+ def repeat(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).repeat(*args)
+ @staticmethod
+ def sack(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sack(*args)
+ @staticmethod
+ def sample(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sample(*args)
+ @staticmethod
+ def select(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).select(*args)
+ @staticmethod
+ def sideEffect(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sideEffect(*args)
+ @staticmethod
+ def simplePath(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).simplePath(*args)
+ @staticmethod
+ def start(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).start(*args)
+ @staticmethod
+ def store(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).store(*args)
+ @staticmethod
+ def subgraph(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).subgraph(*args)
+ @staticmethod
+ def sum(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sum(*args)
+ @staticmethod
+ def tail(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).tail(*args)
+ @staticmethod
+ def timeLimit(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).timeLimit(*args)
+ @staticmethod
+ def times(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).times(*args)
+ @staticmethod
+ def to(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).to(*args)
+ @staticmethod
+ def toE(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).toE(*args)
+ @staticmethod
+ def toV(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).toV(*args)
+ @staticmethod
+ def tree(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).tree(*args)
+ @staticmethod
+ def unfold(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).unfold(*args)
+ @staticmethod
+ def union(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).union(*args)
+ @staticmethod
+ def until(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).until(*args)
+ @staticmethod
+ def value(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).value(*args)
+ @staticmethod
+ def valueMap(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).valueMap(*args)
+ @staticmethod
+ def values(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).values(*args)
+ @staticmethod
+ def where(*args):
+ return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).where(*args)
+
+
+def V(*args):
+ return __.V(*args)
+
+statics['V'] = V
+def _and(*args):
+ return __._and(*args)
+
+statics['_and'] = _and
+def _as(*args):
+ return __._as(*args)
+
+statics['_as'] = _as
+def _in(*args):
+ return __._in(*args)
+
+statics['_in'] = _in
+def _is(*args):
+ return __._is(*args)
+
+statics['_is'] = _is
+def _not(*args):
+ return __._not(*args)
+
+statics['_not'] = _not
+def _or(*args):
+ return __._or(*args)
+
+statics['_or'] = _or
+def addE(*args):
+ return __.addE(*args)
+
+statics['addE'] = addE
+def addInE(*args):
+ return __.addInE(*args)
+
+statics['addInE'] = addInE
+def addOutE(*args):
+ return __.addOutE(*args)
+
+statics['addOutE'] = addOutE
+def addV(*args):
+ return __.addV(*args)
+
+statics['addV'] = addV
+def aggregate(*args):
+ return __.aggregate(*args)
+
+statics['aggregate'] = aggregate
+def barrier(*args):
+ return __.barrier(*args)
+
+statics['barrier'] = barrier
+def both(*args):
+ return __.both(*args)
+
+statics['both'] = both
+def bothE(*args):
+ return __.bothE(*args)
+
+statics['bothE'] = bothE
+def bothV(*args):
+ return __.bothV(*args)
+
+statics['bothV'] = bothV
+def branch(*args):
+ return __.branch(*args)
+
+statics['branch'] = branch
+def cap(*args):
+ return __.cap(*args)
+
+statics['cap'] = cap
+def choose(*args):
+ return __.choose(*args)
+
+statics['choose'] = choose
+def coalesce(*args):
+ return __.coalesce(*args)
+
+statics['coalesce'] = coalesce
+def coin(*args):
+ return __.coin(*args)
+
+statics['coin'] = coin
+def constant(*args):
+ return __.constant(*args)
+
+statics['constant'] = constant
+def count(*args):
+ return __.count(*args)
+
+statics['count'] = count
+def cyclicPath(*args):
+ return __.cyclicPath(*args)
+
+statics['cyclicPath'] = cyclicPath
+def dedup(*args):
+ return __.dedup(*args)
+
+statics['dedup'] = dedup
+def drop(*args):
+ return __.drop(*args)
+
+statics['drop'] = drop
+def emit(*args):
+ return __.emit(*args)
+
+statics['emit'] = emit
+def filter(*args):
+ return __.filter(*args)
+
+statics['filter'] = filter
+def flatMap(*args):
+ return __.flatMap(*args)
+
+statics['flatMap'] = flatMap
+def fold(*args):
+ return __.fold(*args)
+
+statics['fold'] = fold
+def group(*args):
+ return __.group(*args)
+
+statics['group'] = group
+def groupCount(*args):
+ return __.groupCount(*args)
+
+statics['groupCount'] = groupCount
+def groupV3d0(*args):
+ return __.groupV3d0(*args)
+
+statics['groupV3d0'] = groupV3d0
+def has(*args):
+ return __.has(*args)
+
+statics['has'] = has
+def hasId(*args):
+ return __.hasId(*args)
+
+statics['hasId'] = hasId
+def hasKey(*args):
+ return __.hasKey(*args)
+
+statics['hasKey'] = hasKey
+def hasLabel(*args):
+ return __.hasLabel(*args)
+
+statics['hasLabel'] = hasLabel
+def hasNot(*args):
+ return __.hasNot(*args)
+
+statics['hasNot'] = hasNot
+def hasValue(*args):
+ return __.hasValue(*args)
+
+statics['hasValue'] = hasValue
+def id(*args):
+ return __.id(*args)
+
+statics['id'] = id
+def identity(*args):
+ return __.identity(*args)
+
+statics['identity'] = identity
+def inE(*args):
+ return __.inE(*args)
+
+statics['inE'] = inE
+def inV(*args):
+ return __.inV(*args)
+
+statics['inV'] = inV
+def inject(*args):
+ return __.inject(*args)
+
+statics['inject'] = inject
+def key(*args):
+ return __.key(*args)
+
+statics['key'] = key
+def label(*args):
+ return __.label(*args)
+
+statics['label'] = label
+def limit(*args):
+ return __.limit(*args)
+
+statics['limit'] = limit
+def local(*args):
+ return __.local(*args)
+
+statics['local'] = local
+def loops(*args):
+ return __.loops(*args)
+
+statics['loops'] = loops
+def map(*args):
+ return __.map(*args)
+
+statics['map'] = map
+def mapKeys(*args):
+ return __.mapKeys(*args)
+
+statics['mapKeys'] = mapKeys
+def mapValues(*args):
+ return __.mapValues(*args)
+
+statics['mapValues'] = mapValues
+def match(*args):
+ return __.match(*args)
+
+statics['match'] = match
+def max(*args):
+ return __.max(*args)
+
+statics['max'] = max
+def mean(*args):
+ return __.mean(*args)
+
+statics['mean'] = mean
+def min(*args):
+ return __.min(*args)
+
+statics['min'] = min
+def optional(*args):
+ return __.optional(*args)
+
+statics['optional'] = optional
+def order(*args):
+ return __.order(*args)
+
+statics['order'] = order
+def otherV(*args):
+ return __.otherV(*args)
+
+statics['otherV'] = otherV
+def out(*args):
+ return __.out(*args)
+
+statics['out'] = out
+def outE(*args):
+ return __.outE(*args)
+
+statics['outE'] = outE
+def outV(*args):
+ return __.outV(*args)
+
+statics['outV'] = outV
+def path(*args):
+ return __.path(*args)
+
+statics['path'] = path
+def project(*args):
+ return __.project(*args)
+
+statics['project'] = project
+def properties(*args):
+ return __.properties(*args)
+
+statics['properties'] = properties
+def property(*args):
+ return __.property(*args)
+
+statics['property'] = property
+def propertyMap(*args):
+ return __.propertyMap(*args)
+
+statics['propertyMap'] = propertyMap
+def range(*args):
+ return __.range(*args)
+
+statics['range'] = range
+def repeat(*args):
+ return __.repeat(*args)
+
+statics['repeat'] = repeat
+def sack(*args):
+ return __.sack(*args)
+
+statics['sack'] = sack
+def sample(*args):
+ return __.sample(*args)
+
+statics['sample'] = sample
+def select(*args):
+ return __.select(*args)
+
+statics['select'] = select
+def sideEffect(*args):
+ return __.sideEffect(*args)
+
+statics['sideEffect'] = sideEffect
+def simplePath(*args):
+ return __.simplePath(*args)
+
+statics['simplePath'] = simplePath
+def start(*args):
+ return __.start(*args)
+
+statics['start'] = start
+def store(*args):
+ return __.store(*args)
+
+statics['store'] = store
+def subgraph(*args):
+ return __.subgraph(*args)
+
+statics['subgraph'] = subgraph
+def sum(*args):
+ return __.sum(*args)
+
+statics['sum'] = sum
+def tail(*args):
+ return __.tail(*args)
+
+statics['tail'] = tail
+def timeLimit(*args):
+ return __.timeLimit(*args)
+
+statics['timeLimit'] = timeLimit
+def times(*args):
+ return __.times(*args)
+
+statics['times'] = times
+def to(*args):
+ return __.to(*args)
+
+statics['to'] = to
+def toE(*args):
+ return __.toE(*args)
+
+statics['toE'] = toE
+def toV(*args):
+ return __.toV(*args)
+
+statics['toV'] = toV
+def tree(*args):
+ return __.tree(*args)
+
+statics['tree'] = tree
+def unfold(*args):
+ return __.unfold(*args)
+
+statics['unfold'] = unfold
+def union(*args):
+ return __.union(*args)
+
+statics['union'] = union
+def until(*args):
+ return __.until(*args)
+
+statics['until'] = until
+def value(*args):
+ return __.value(*args)
+
+statics['value'] = value
+def valueMap(*args):
+ return __.valueMap(*args)
+
+statics['valueMap'] = valueMap
+def values(*args):
+ return __.values(*args)
+
+statics['values'] = values
+def where(*args):
+ return __.where(*args)
+
+statics['where'] = where
+
+
+Cardinality = Enum('Cardinality', 'single list set')
+
+statics['single'] = Cardinality.single
+statics['list'] = Cardinality.list
+statics['set'] = Cardinality.set
+
+Column = Enum('Column', 'keys values')
+
+statics['keys'] = Column.keys
+statics['values'] = Column.values
+
+Direction = Enum('Direction', 'OUT IN BOTH')
+
+statics['OUT'] = Direction.OUT
+statics['IN'] = Direction.IN
+statics['BOTH'] = Direction.BOTH
+
+Operator = Enum('Operator', 'sum minus mult div min max assign _and _or addAll sumLong')
+
+statics['sum'] = Operator.sum
+statics['minus'] = Operator.minus
+statics['mult'] = Operator.mult
+statics['div'] = Operator.div
+statics['min'] = Operator.min
+statics['max'] = Operator.max
+statics['assign'] = Operator.assign
+statics['_and'] = Operator._and
+statics['_or'] = Operator._or
+statics['addAll'] = Operator.addAll
+statics['sumLong'] = Operator.sumLong
+
+Order = Enum('Order', 'incr decr keyIncr valueIncr keyDecr valueDecr shuffle')
+
+statics['incr'] = Order.incr
+statics['decr'] = Order.decr
+statics['keyIncr'] = Order.keyIncr
+statics['valueIncr'] = Order.valueIncr
+statics['keyDecr'] = Order.keyDecr
+statics['valueDecr'] = Order.valueDecr
+statics['shuffle'] = Order.shuffle
+
+Pop = Enum('Pop', 'first last all')
+
+statics['first'] = Pop.first
+statics['last'] = Pop.last
+statics['all'] = Pop.all
+
+Barrier = Enum('Barrier', 'normSack')
+
+statics['normSack'] = Barrier.normSack
+
+Scope = Enum('Scope', '_global local')
+
+statics['_global'] = Scope._global
+statics['local'] = Scope.local
+
+T = Enum('T', 'label id key value')
+
+statics['label'] = T.label
+statics['id'] = T.id
+statics['key'] = T.key
+statics['value'] = T.value
+
+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)
+
+class Raw(object):
+ def __init__(self, value):
+ self.value = value
+
+ def __str__(self):
+ return str(self.value)
+
+class P(object):
+ def __init__(self, operator, value, other=None):
+ self.operator = operator
+ self.value = value
+ self.other = other
+ @staticmethod
+ def _not(*args):
+ return P("not", *args)
+ @staticmethod
+ def between(*args):
+ return P("between", *args)
+ @staticmethod
+ def eq(*args):
+ return P("eq", *args)
+ @staticmethod
+ def gt(*args):
+ return P("gt", *args)
+ @staticmethod
+ def gte(*args):
+ return P("gte", *args)
+ @staticmethod
+ def inside(*args):
+ return P("inside", *args)
+ @staticmethod
+ def lt(*args):
+ return P("lt", *args)
+ @staticmethod
+ def lte(*args):
+ return P("lte", *args)
+ @staticmethod
+ def negate(*args):
+ return P("negate", *args)
+ @staticmethod
+ def neq(*args):
+ return P("neq", *args)
+ @staticmethod
+ def outside(*args):
+ return P("outside", *args)
+ @staticmethod
+ def test(*args):
+ return P("test", *args)
+ @staticmethod
+ def within(*args):
+ return P("within", *args)
+ @staticmethod
+ def without(*args):
+ return P("without", *args)
+ def _and(self, arg):
+ return P("_and", arg, self)
+ def _or(self, arg):
+ return P("_or", arg, self)
+
+def _and(*args):
+ return P._and(*args)
+
+statics['_and'] = _and
+def _not(*args):
+ return P._not(*args)
+
+statics['_not'] = _not
+def _or(*args):
+ return P._or(*args)
+
+statics['_or'] = _or
+def between(*args):
+ return P.between(*args)
+
+statics['between'] = between
+def eq(*args):
+ return P.eq(*args)
+
+statics['eq'] = eq
+def gt(*args):
+ return P.gt(*args)
+
+statics['gt'] = gt
+def gte(*args):
+ return P.gte(*args)
+
+statics['gte'] = gte
+def inside(*args):
+ return P.inside(*args)
+
+statics['inside'] = inside
+def lt(*args):
+ return P.lt(*args)
+
+statics['lt'] = lt
+def lte(*args):
+ return P.lte(*args)
+
+statics['lte'] = lte
+def negate(*args):
+ return P.negate(*args)
+
+statics['negate'] = negate
+def neq(*args):
+ return P.neq(*args)
+
+statics['neq'] = neq
+def outside(*args):
+ return P.outside(*args)
+
+statics['outside'] = outside
+def test(*args):
+ return P.test(*args)
+
+statics['test'] = test
+def within(*args):
+ return P.within(*args)
+
+statics['within'] = within
+def without(*args):
+ return P.without(*args)
+
+statics['without'] = without
+
+statics = OrderedDict(reversed(list(statics.items())))
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_python/groovy_translator.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/groovy_translator.py b/gremlin-python/src/main/jython/gremlin_python/groovy_translator.py
new file mode 100644
index 0000000..2cd60be
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/groovy_translator.py
@@ -0,0 +1,121 @@
+'''
+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.
+'''
+
+import sys
+from aenum import Enum
+
+from gremlin_python import P
+from gremlin_python import Raw
+from gremlin_python import RawExpression
+from translator import Translator
+
+if sys.version_info.major > 2:
+ long = int
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+methodMap = {"_global": "global", "_as": "as", "_in": "in", "_and": "and", "_or": "or", "_is": "is", "_not": "not",
+ "_from": "from"}
+
+enumMap = {"Cardinality": "VertexProperty.Cardinality", "Barrier": "SackFunctions.Barrier"}
+
+
+class GroovyTranslator(Translator):
+ def __init__(self, alias, source_language="python", target_language="gremlin-groovy"):
+ Translator.__init__(self, alias, source_language, target_language)
+
+ def addStep(self, traversal, step_name, *args):
+ self.traversal_script = self.traversal_script + "." + GroovyTranslator.mapMethod(
+ step_name) + "(" + GroovyTranslator.stringify(*args) + ")"
+
+ def addSpawnStep(self, traversal, step_name, *args):
+ newTranslator = GroovyTranslator(self.alias, self.source_language)
+ newTranslator.traversal_script = self.traversal_script
+ newTranslator.traversal_script = newTranslator.traversal_script + "." + GroovyTranslator.mapMethod(
+ step_name) + "(" + GroovyTranslator.stringify(*args) + ")"
+ traversal.translator = newTranslator
+
+ def addSource(self, traversal_source, source_name, *args):
+ newTranslator = GroovyTranslator(self.alias, self.source_language)
+ newTranslator.traversal_script = self.traversal_script
+ newTranslator.traversal_script = newTranslator.traversal_script + "." + GroovyTranslator.mapMethod(
+ source_name) + "(" + GroovyTranslator.stringify(*args) + ")"
+ traversal_source.translator = newTranslator
+
+ def getAnonymousTraversalTranslator(self):
+ return GroovyTranslator("__", self.source_language)
+
+ ### HELPER METHODS ###
+
+ @staticmethod
+ def mapMethod(method):
+ if (method in methodMap):
+ return methodMap[method]
+ else:
+ return method
+
+ @staticmethod
+ def mapEnum(enum):
+ if (enum in enumMap):
+ return enumMap[enum]
+ else:
+ return enum
+
+ @staticmethod
+ def stringOrObject(arg):
+ if isinstance(arg, str):
+ return "\"" + arg + "\""
+ elif isinstance(arg, bool):
+ return str(arg).lower()
+ elif isinstance(arg, long):
+ return str(arg) + "L"
+ elif isinstance(arg, float):
+ return str(arg) + "f"
+ elif isinstance(arg, Enum): # Column, Order, Direction, Scope, T, etc.
+ return GroovyTranslator.mapEnum(type(arg).__name__) + "." + GroovyTranslator.mapMethod(str(arg.name))
+ elif isinstance(arg, P):
+ if arg.other is None:
+ return "P." + GroovyTranslator.mapMethod(arg.operator) + "(" + GroovyTranslator.stringOrObject(
+ arg.value) + ")"
+ else:
+ return GroovyTranslator.stringOrObject(arg.other) + "." + GroovyTranslator.mapMethod(
+ arg.operator) + "(" + GroovyTranslator.stringOrObject(arg.value) + ")"
+ elif callable(arg): # closures
+ lambdaString = arg().strip()
+ if lambdaString.startswith("{"):
+ return lambdaString
+ else:
+ return "{" + lambdaString + "}"
+ elif isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str): # bindings
+ return arg[0]
+ elif isinstance(arg, RawExpression):
+ return "".join(GroovyTranslator.stringOrObject(i) for i in arg.parts)
+ elif isinstance(arg, Raw):
+ return str(arg)
+ else:
+ return str(arg)
+
+ @staticmethod
+ def stringify(*args):
+ if len(args) == 0:
+ return ""
+ elif len(args) == 1:
+ return GroovyTranslator.stringOrObject(args[0])
+ else:
+ return ", ".join(GroovyTranslator.stringOrObject(i) for i in args)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_python/translator.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/translator.py b/gremlin-python/src/main/jython/gremlin_python/translator.py
new file mode 100644
index 0000000..9376554
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/translator.py
@@ -0,0 +1,49 @@
+'''
+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.
+'''
+from abc import abstractmethod
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+
+class Translator(object):
+ def __init__(self, alias, source_language, target_language):
+ self.alias = alias
+ self.source_language = source_language
+ self.target_language = target_language
+ self.traversal_script = alias
+
+ @abstractmethod
+ def addStep(self, traversal, step_name, *args):
+ return
+
+ @abstractmethod
+ def addSpawnStep(self, traversal, step_name, *args):
+ return
+
+ @abstractmethod
+ def addSource(self, traversal_source, source_name, *args):
+ return
+
+ @abstractmethod
+ def getAnonymousTraversalTranslator(self):
+ return Translator("__", self.source_language, self.target_language)
+
+ @abstractmethod
+ def __repr__(self):
+ return "translator[" + self.source_language + "->" + self.target_language + "]"
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_rest_driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_rest_driver/__init__.py b/gremlin-python/src/main/jython/gremlin_rest_driver/__init__.py
new file mode 100644
index 0000000..8ae13f8
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_rest_driver/__init__.py
@@ -0,0 +1,21 @@
+'''
+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.
+'''
+from gremlin_rest_driver import RESTRemoteConnection
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py b/gremlin-python/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
new file mode 100644
index 0000000..b265752
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
@@ -0,0 +1,41 @@
+'''
+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.
+'''
+import json
+import requests
+from gremlin_driver import RemoteConnection
+from gremlin_driver import Traverser
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+
+class RESTRemoteConnection(RemoteConnection):
+ def __init__(self, url):
+ RemoteConnection.__init__(self, url)
+
+ def __repr__(self):
+ return "RESTRemoteConnection[" + self.url + "]"
+
+ def submit(self, target_language, script, bindings):
+ response = requests.post(self.url, data=json.dumps({"gremlin": script, "language": target_language, "bindings": bindings}))
+ if response.status_code != requests.codes.ok:
+ raise BaseException(response.text)
+ results = []
+ for x in response.json()['result']['data']:
+ results.append(Traverser(x, 1))
+ return iter(results)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/setup.cfg
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.cfg b/gremlin-python/src/main/jython/setup.cfg
new file mode 100644
index 0000000..de959fe
--- /dev/null
+++ b/gremlin-python/src/main/jython/setup.cfg
@@ -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.
+[bdist_wheel]
+universal=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
new file mode 100644
index 0000000..05f1dc3
--- /dev/null
+++ b/gremlin-python/src/main/jython/setup.py
@@ -0,0 +1,58 @@
+'''
+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.
+'''
+import os
+import time
+import codecs
+
+from setuptools import setup
+
+# Folder containing the setup.py
+root = os.path.dirname(os.path.abspath(__file__))
+
+# Path to __version__ module
+version_file = os.path.join(root, '.', '__version__.py')
+
+# Check if this is a source distribution.
+# If not create the __version__ module containing the version
+if not os.path.exists(os.path.join(root, 'PKG-INFO')):
+ timestamp = int(os.getenv('TIMESTAMP', time.time() * 1000)) / 1000
+ fd = codecs.open(version_file, 'w', 'utf-8')
+ fd.write("'''")
+ fd.write(__doc__)
+ fd.write("'''\n")
+ fd.write('version = %r\n' % os.getenv('VERSION', '?').replace('-SNAPSHOT', '.dev-%d' % timestamp))
+ fd.write('timestamp = %d\n' % timestamp)
+ fd.close()
+# Load version
+import __version__
+version = __version__.version
+
+setup(
+ name='gremlinpython',
+ version=version,
+ packages=['gremlin_driver','gremlin_python', 'gremlin_rest_driver'],
+ license='Apache 2',
+ url='http://tinkerpop.apache.org',
+ description='Gremlin Language Variant for Apache TinkerPop - Gremlin',
+ long_description=open("README").read(),
+ install_requires=[
+ 'aenum',
+ 'requests'
+ ]
+)
[3/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.
Posted by ok...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/PythonTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/PythonTranslator.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/PythonTranslator.java
deleted file mode 100644
index 479d3af..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/PythonTranslator.java
+++ /dev/null
@@ -1,218 +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.python;
-
-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 "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-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
deleted file mode 100644
index 090fa5c..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ /dev/null
@@ -1,126 +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.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-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
deleted file mode 100644
index 81256ea..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
+++ /dev/null
@@ -1,115 +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.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-variant/src/main/jython/LICENSE
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/LICENSE b/gremlin-variant/src/main/jython/LICENSE
deleted file mode 100644
index 7a4a3ea..0000000
--- a/gremlin-variant/src/main/jython/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- 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-variant/src/main/jython/MANIFEST.in
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/MANIFEST.in b/gremlin-variant/src/main/jython/MANIFEST.in
deleted file mode 100644
index c7cc6dc..0000000
--- a/gremlin-variant/src/main/jython/MANIFEST.in
+++ /dev/null
@@ -1,18 +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.
-include LICENSE
-include NOTICE
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/NOTICE
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/NOTICE b/gremlin-variant/src/main/jython/NOTICE
deleted file mode 100644
index 90e77a8..0000000
--- a/gremlin-variant/src/main/jython/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-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
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/README
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/README b/gremlin-variant/src/main/jython/README
deleted file mode 100644
index e7ad5fb..0000000
--- a/gremlin-variant/src/main/jython/README
+++ /dev/null
@@ -1,18 +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.
-
-Apache TinkerPop - Gremlin Python - Gremlin Language Variant
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_driver/__init__.py b/gremlin-variant/src/main/jython/gremlin_driver/__init__.py
deleted file mode 100644
index dcbd144..0000000
--- a/gremlin-variant/src/main/jython/gremlin_driver/__init__.py
+++ /dev/null
@@ -1,22 +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.
-'''
-from gremlin_driver import RemoteConnection
-from gremlin_driver import Traverser
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_driver/gremlin_driver.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_driver/gremlin_driver.py b/gremlin-variant/src/main/jython/gremlin_driver/gremlin_driver.py
deleted file mode 100644
index 96939d4..0000000
--- a/gremlin-variant/src/main/jython/gremlin_driver/gremlin_driver.py
+++ /dev/null
@@ -1,39 +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.
-'''
-from abc import abstractmethod
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-
-class Traverser(object):
- def __init__(self, object, bulk):
- self.object = object
- self.bulk = bulk
- def __repr__(self):
- return str(self.object)
-
-
-class RemoteConnection(object):
- def __init__(self, url):
- self.url = url
-
- @abstractmethod
- def submit(self, target_language, script, bindings):
- print "sending " + script + " to GremlinServer..."
- return iter([])
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_python/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_python/__init__.py b/gremlin-variant/src/main/jython/gremlin_python/__init__.py
deleted file mode 100644
index e9e2fa5..0000000
--- a/gremlin-variant/src/main/jython/gremlin_python/__init__.py
+++ /dev/null
@@ -1,35 +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.
-'''
-from gremlin_python import PythonGraphTraversal
-from gremlin_python import PythonGraphTraversalSource
-from gremlin_python import __
-from gremlin_python import statics
-from gremlin_python import T
-from gremlin_python import Order
-from gremlin_python import Cardinality
-from gremlin_python import Column
-from gremlin_python import Direction
-from gremlin_python import Operator
-from gremlin_python import P
-from gremlin_python import Pop
-from gremlin_python import Scope
-from gremlin_python import Barrier
-from groovy_translator import GroovyTranslator
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
\ No newline at end of file
[4/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.
Posted by ok...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonBypassTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonBypassTranslator.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonBypassTranslator.java
new file mode 100644
index 0000000..0bbde96
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonBypassTranslator.java
@@ -0,0 +1,88 @@
+/*
+ * 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.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.util.Translator;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+class PythonBypassTranslator extends PythonTranslator {
+
+ private PythonBypassTranslator(final String alias, final boolean importStatics) {
+ super(alias, importStatics);
+ }
+
+ public static PythonBypassTranslator of(final String alias) {
+ return new PythonBypassTranslator(alias, false);
+ }
+
+ public static PythonBypassTranslator of(final String alias, final boolean importStatics) {
+ return new PythonBypassTranslator(alias, importStatics);
+ }
+
+ @Override
+ public void addStep(final Traversal.Admin<?, ?> traversal, final String stepName, final Object... arguments) {
+ super.addStep(traversal, stepName, arguments);
+ if (!this.importStatics)
+ assert this.traversalScript.toString().startsWith(this.alias + ".");
+ }
+
+ @Override
+ public Translator getAnonymousTraversalTranslator() {
+ return new PythonBypassTranslator("__", this.importStatics);
+ }
+
+ @Override
+ public String getTargetLanguage() {
+ return "gremlin-groovy";
+ }
+
+ @Override
+ public String getTraversalScript() {
+ final String traversal = super.getTraversalScript();
+ if (!this.alias.equals("__")) {
+ try {
+ final ScriptEngine jythonEngine = ScriptEngineCache.get("gremlin-jython");
+ final Bindings jythonBindings = new SimpleBindings();
+ jythonBindings.put(this.alias, jythonEngine.eval("PythonGraphTraversalSource(GroovyTranslator(\"" + this.alias + "\"))"));
+ jythonEngine.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
+ return jythonEngine.eval(traversal).toString();
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
+ }
+ } else
+ return traversal;
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.translatorString(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslatorTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslatorTest.java
new file mode 100644
index 0000000..adce9ee
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/PythonTranslatorTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.traversal.Traverser;
+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.python.jsr223.GremlinJythonScriptEngineSetup;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.apache.tinkerpop.gremlin.util.function.Lambda;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class PythonTranslatorTest {
+
+ static {
+ GremlinJythonScriptEngineSetup.setup();
+ }
+
+ @Test
+ public void shouldSupportStringSupplierLambdas() throws Exception {
+ final GraphTraversalSource g = TinkerFactory.createModern().traversal().withTranslator(PythonBypassTranslator.of("g", true));
+ GraphTraversal.Admin<Vertex, Integer> t = g.withSideEffect("lengthSum", 0).withSack(1)
+ .V()
+ .filter(Lambda.predicate("lambda: \"it.get().label().equals('person')\""))
+ .flatMap(Lambda.<Traverser<Vertex>, Iterator<Vertex>>function("it.get().vertices(Direction.OUT)"))
+ .map(Lambda.<Traverser<Vertex>, Integer>function("it.get().value('name').length()"))
+ .sideEffect(Lambda.consumer("x -> x.sideEffects('lengthSum', x.<Integer>sideEffects('lengthSum') + x.get())"))
+ .order().by(Lambda.comparator("a,b -> a <=> b"))
+ .sack(Lambda.biFunction("lambda : \"a,b -> a + b\""))
+ .asAdmin();
+ final List<Integer> sacks = new ArrayList<>();
+ final List<Integer> lengths = new ArrayList<>();
+ while (t.hasNext()) {
+ final Traverser.Admin<Integer> traverser = t.getEndStep().next();
+ sacks.add(traverser.sack());
+ lengths.add(traverser.get());
+ }
+ assertFalse(t.hasNext());
+ //
+ assertEquals(6, lengths.size());
+ assertEquals(3, lengths.get(0).intValue());
+ assertEquals(3, lengths.get(1).intValue());
+ assertEquals(3, lengths.get(2).intValue());
+ assertEquals(4, lengths.get(3).intValue());
+ assertEquals(5, lengths.get(4).intValue());
+ assertEquals(6, lengths.get(5).intValue());
+ ///
+ assertEquals(6, sacks.size());
+ assertEquals(4, sacks.get(0).intValue());
+ assertEquals(4, sacks.get(1).intValue());
+ assertEquals(4, sacks.get(2).intValue());
+ assertEquals(5, sacks.get(3).intValue());
+ assertEquals(6, sacks.get(4).intValue());
+ assertEquals(7, sacks.get(5).intValue());
+ //
+ assertEquals(24, t.getSideEffects().<Number>get("lengthSum").intValue());
+ }
+
+ @Test
+ public void shouldHaveValidToString() {
+ assertEquals("translator[h:gremlin-java->gremlin-jython]", PythonTranslator.of("h").toString());
+ assertEquals("translator[h:gremlin-java->gremlin-groovy]", PythonBypassTranslator.of("h").toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorComputerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorComputerProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorComputerProvider.java
new file mode 100644
index 0000000..6dcf40b
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorComputerProvider.java
@@ -0,0 +1,37 @@
+/*
+ * 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.GraphProvider;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
+public class TinkerGraphPythonTranslatorComputerProvider extends TinkerGraphPythonTranslatorProvider {
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ return super.traversal(graph).withComputer();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessComputerTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessComputerTest.java
new file mode 100644
index 0000000..2abf94a
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessComputerTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessComputerSuite.class)
+@GraphProviderClass(provider = TinkerGraphPythonTranslatorComputerProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphPythonTranslatorProcessComputerTest {
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessStandardTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessStandardTest.java
new file mode 100644
index 0000000..e393d88
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProcessStandardTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessStandardSuite.class)
+@GraphProviderClass(provider = TinkerGraphPythonTranslatorProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphPythonTranslatorProcessStandardTest {
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProvider.java
new file mode 100644
index 0000000..507b7c3
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/java/translator/TinkerGraphPythonTranslatorProvider.java
@@ -0,0 +1,150 @@
+/*
+ * 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.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.AbstractGraphProvider;
+import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
+import org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngineSetup;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+
+import javax.script.ScriptException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class TinkerGraphPythonTranslatorProvider extends AbstractGraphProvider {
+
+ private static final boolean IMPORT_STATICS = new Random().nextBoolean();
+
+ static {
+ GremlinJythonScriptEngineSetup.setup();
+ }
+
+ private static Set<String> SKIP_TESTS = new HashSet<>(Arrays.asList(
+ "testProfileStrategyCallback",
+ "testProfileStrategyCallbackSideEffect",
+ "g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX",
+ "g_V_both_hasLabelXpersonX_order_byXage_decrX_name",
+ "g_VX1X_out_injectXv2X_name",
+ "shouldSupportGraphFilter",
+ "shouldNeverPropagateANoBulkTraverser",
+ "shouldNeverPropagateANullValuedTraverser",
+ "shouldTraversalResetProperly",
+ "shouldHidePartitionKeyForValues",
+ ProgramTest.Traversals.class.getCanonicalName(),
+ TraversalInterruptionTest.class.getCanonicalName(),
+ TraversalInterruptionComputerTest.class.getCanonicalName(),
+ ElementIdStrategyProcessTest.class.getCanonicalName()));
+
+ private static final Set<Class> IMPLEMENTATION = new HashSet<Class>() {{
+ add(TinkerEdge.class);
+ add(TinkerElement.class);
+ add(TinkerGraph.class);
+ add(TinkerGraphVariables.class);
+ add(TinkerProperty.class);
+ add(TinkerVertex.class);
+ add(TinkerVertexProperty.class);
+ }};
+
+ @Override
+ public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName,
+ final LoadGraphWith.GraphData loadGraphWith) {
+
+ final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith);
+ final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromGraphData(loadGraphWith) : idManager).name();
+ return new HashMap<String, Object>() {{
+ put(Graph.GRAPH, TinkerGraph.class.getName());
+ put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker);
+ put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker);
+ put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker);
+ put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName()));
+ if (loadGraphWith == LoadGraphWith.GraphData.CREW)
+ put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
+ }};
+ }
+
+ @Override
+ public void clear(final Graph graph, final Configuration configuration) throws Exception {
+ if (graph != null) graph.close();
+ }
+
+ @Override
+ public Set<Class> getImplementations() {
+ return IMPLEMENTATION;
+ }
+
+ /**
+ * Test that load with specific graph data can be configured with a specific id manager as the data type to
+ * be used in the test for that graph is known.
+ */
+ protected TinkerGraph.DefaultIdManager selectIdMakerFromGraphData(final LoadGraphWith.GraphData loadGraphWith) {
+ if (null == loadGraphWith) return TinkerGraph.DefaultIdManager.ANY;
+ if (loadGraphWith.equals(LoadGraphWith.GraphData.CLASSIC))
+ return TinkerGraph.DefaultIdManager.INTEGER;
+ else if (loadGraphWith.equals(LoadGraphWith.GraphData.MODERN))
+ return TinkerGraph.DefaultIdManager.INTEGER;
+ else if (loadGraphWith.equals(LoadGraphWith.GraphData.CREW))
+ return TinkerGraph.DefaultIdManager.INTEGER;
+ else if (loadGraphWith.equals(LoadGraphWith.GraphData.GRATEFUL))
+ return TinkerGraph.DefaultIdManager.INTEGER;
+ else
+ throw new IllegalStateException(String.format("Need to define a new %s for %s", TinkerGraph.IdManager.class.getName(), loadGraphWith.name()));
+ }
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ if ((Boolean) graph.configuration().getProperty("skipTest"))
+ return graph.traversal();
+ //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance());
+ else {
+ try {
+ if (IMPORT_STATICS)
+ ScriptEngineCache.get("gremlin-jython").eval("for k in statics:\n globals()[k] = statics[k]");
+ else
+ ScriptEngineCache.get("gremlin-jython").eval("for k in statics:\n if k in globals():\n del globals()[k]");
+ } catch (final ScriptException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ return graph.traversal().withTranslator(PythonBypassTranslator.of("g", IMPORT_STATICS)); // the bypass translator will ensure that gremlin-groovy is ultimately used
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
new file mode 100644
index 0000000..686c1bc
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/driver/RESTRemoteConnectionTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.driver;
+
+import org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngineSetup;
+import org.apache.tinkerpop.gremlin.server.GremlinServer;
+import org.apache.tinkerpop.gremlin.server.Settings;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.SimpleBindings;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class RESTRemoteConnectionTest {
+
+ private final ScriptEngine jython = ScriptEngineCache.get("gremlin-jython");
+
+ @Before
+ public void setup() {
+ try {
+ GremlinJythonScriptEngineSetup.setup();
+ final Bindings jythonBindings = new SimpleBindings();
+ jythonBindings.put("g", jython.eval("PythonGraphTraversalSource(GroovyTranslator('g'), RESTRemoteConnection('http://localhost:8182'))"));
+ jython.getContext().setBindings(jythonBindings, ScriptContext.GLOBAL_SCOPE);
+ final GremlinServer server = new GremlinServer(Settings.read(RESTRemoteConnectionTest.class.getResourceAsStream("gremlin-server-rest-modern.yaml")));
+ server.start().join();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRESTRemoteConnection() throws Exception {
+ final List<String> results = (List) jython.eval("g.V().repeat(__.out()).times(2).name.toList()");
+ assertEquals(2, results.size());
+ assertTrue(results.contains("lop"));
+ assertTrue(results.contains("ripple"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineSetup.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineSetup.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineSetup.java
new file mode 100644
index 0000000..9cb3270
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineSetup.java
@@ -0,0 +1,46 @@
+/*
+ * 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.ScriptEngineCache;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GremlinJythonScriptEngineSetup {
+
+ private GremlinJythonScriptEngineSetup() {
+ }
+
+ public static void setup() {
+ try {
+ final ScriptEngine jythonEngine = ScriptEngineCache.get("gremlin-jython");
+ jythonEngine.eval("from gremlin_python.gremlin_python import *");
+ jythonEngine.eval("from gremlin_python.gremlin_python import __");
+ jythonEngine.eval("from gremlin_python.groovy_translator import GroovyTranslator");
+ jythonEngine.eval("from gremlin_rest_driver import RESTRemoteConnection");
+ } catch (final ScriptException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
new file mode 100644
index 0000000..7582877
--- /dev/null
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.junit.Test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GremlinJythonScriptEngineTest {
+
+ @Test
+ public void shouldGetEngineByName() throws Exception {
+ final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
+ assertNotNull(engine);
+ assertTrue(engine instanceof GremlinJythonScriptEngine);
+ assertTrue(engine.eval("Graph") instanceof Class);
+ assertEquals(3, engine.eval("1+2"));
+ }
+
+ @Test
+ public void shouldHaveStandardImports() throws Exception {
+ final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
+ assertTrue(engine.eval("Graph") instanceof Class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory b/gremlin-python/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
new file mode 100644
index 0000000..92f4825
--- /dev/null
+++ b/gremlin-python/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
@@ -0,0 +1 @@
+org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngineFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/resources/log4j-silent.properties
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/resources/log4j-silent.properties b/gremlin-python/src/test/resources/log4j-silent.properties
new file mode 100644
index 0000000..1825bb0
--- /dev/null
+++ b/gremlin-python/src/test/resources/log4j-silent.properties
@@ -0,0 +1,23 @@
+# 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.
+
+# this file should always have logging set to OFF. it seems, however, that an appender of some sort is
+# required or else some logs throw error and use other log4j.properties files on the path.
+log4j.rootLogger=OFF, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/resources/log4j-test.properties b/gremlin-python/src/test/resources/log4j-test.properties
new file mode 100644
index 0000000..79038b1
--- /dev/null
+++ b/gremlin-python/src/test/resources/log4j-test.properties
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+log4j.rootLogger=WARN, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-rest-modern.yaml
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-rest-modern.yaml b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-rest-modern.yaml
new file mode 100644
index 0000000..3a54a0c
--- /dev/null
+++ b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-rest-modern.yaml
@@ -0,0 +1,45 @@
+# 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.
+
+host: localhost
+port: 8182
+threadPoolWorker: 1
+gremlinPool: 8
+scriptEvaluationTimeout: 30000
+channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
+graphs: {
+ graph: ../gremlin-server/conf/tinkergraph-empty.properties}
+plugins:
+ - tinkerpop.tinkergraph
+scriptEngines: {
+ gremlin-groovy: {
+ imports: [java.lang.Math],
+ staticImports: [java.lang.Math.PI],
+ scripts: [../gremlin-server/scripts/generate-modern.groovy]}}
+serializers:
+ - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+ - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/json
+metrics: {
+ slf4jReporter: {enabled: true, interval: 180000}}
+strictTransactionManagement: false
+threadPoolBoss: 1
+maxInitialLineLength: 4096
+maxHeaderSize: 8192
+maxChunkSize: 8192
+maxContentLength: 65536
+maxAccumulationBufferComponents: 1024
+resultIterationBatchSize: 64
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorComputerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorComputerProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorComputerProvider.java
deleted file mode 100644
index 376ac16..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorComputerProvider.java
+++ /dev/null
@@ -1,54 +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.driver.remote;
-
-import org.apache.tinkerpop.gremlin.GraphProvider;
-import org.apache.tinkerpop.gremlin.process.computer.Computer;
-import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
-
-import java.util.Random;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
-public class RemoteGraphTranslatorComputerProvider extends RemoteGraphTranslatorProvider {
-
- private final Random RANDOM = new Random();
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- assert graph instanceof RemoteGraph;
- final int state = RANDOM.nextInt(3);
- switch (state) {
- case 0:
- return super.traversal(graph).withComputer();
- case 1:
- return super.traversal(graph).withComputer(Computer.compute(TinkerGraphComputer.class));
- case 2:
- return super.traversal(graph).withComputer(Computer.compute(TinkerGraphComputer.class).workers(1));
- default:
- throw new IllegalStateException("This state should not have occurred: " + state);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorProvider.java
deleted file mode 100644
index 17d7328..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphTranslatorProvider.java
+++ /dev/null
@@ -1,35 +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.driver.remote;
-
-import org.apache.tinkerpop.gremlin.groovy.GroovyTranslator;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class RemoteGraphTranslatorProvider extends RemoteGraphProvider {
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- return graph.traversal().withTranslator(GroovyTranslator.of("g"));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorComputerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorComputerProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorComputerProvider.java
new file mode 100644
index 0000000..9eae953
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorComputerProvider.java
@@ -0,0 +1,54 @@
+/*
+ * 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.GraphProvider;
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
+
+import java.util.Random;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
+public class RemoteGraphGroovyTranslatorComputerProvider extends RemoteGraphGroovyTranslatorProvider {
+
+ private final Random RANDOM = new Random();
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ assert graph instanceof RemoteGraph;
+ final int state = RANDOM.nextInt(3);
+ switch (state) {
+ case 0:
+ return super.traversal(graph).withComputer();
+ case 1:
+ return super.traversal(graph).withComputer(Computer.compute(TinkerGraphComputer.class));
+ case 2:
+ return super.traversal(graph).withComputer(Computer.compute(TinkerGraphComputer.class).workers(1));
+ default:
+ throw new IllegalStateException("This state should not have occurred: " + state);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessComputerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessComputerTest.java
new file mode 100644
index 0000000..a45ab2d
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessComputerTest.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.java.translator;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessComputerSuite.class)
+@GraphProviderClass(provider = RemoteGraphGroovyTranslatorComputerProvider.class, graph = RemoteGraph.class)
+public class RemoteGraphGroovyTranslatorProcessComputerTest {
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessStandardTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessStandardTest.java
new file mode 100644
index 0000000..3c2365c
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProcessStandardTest.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.java.translator;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessStandardSuite.class)
+@GraphProviderClass(provider = RemoteGraphGroovyTranslatorProvider.class, graph = RemoteGraph.class)
+public class RemoteGraphGroovyTranslatorProcessStandardTest {
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProvider.java
new file mode 100644
index 0000000..011d42e
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/java/translator/RemoteGraphGroovyTranslatorProvider.java
@@ -0,0 +1,35 @@
+/*
+ * 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.driver.remote.RemoteGraphProvider;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class RemoteGraphGroovyTranslatorProvider extends RemoteGraphProvider {
+
+ @Override
+ public GraphTraversalSource traversal(final Graph graph) {
+ return graph.traversal().withTranslator(GroovyTranslator.of("g"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessComputerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessComputerTest.java
deleted file mode 100644
index c4d79c1..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessComputerTest.java
+++ /dev/null
@@ -1,34 +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.remote.process;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.driver.remote.RemoteGraphTranslatorComputerProvider;
-import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
-import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessComputerSuite.class)
-@GraphProviderClass(provider = RemoteGraphTranslatorComputerProvider.class, graph = RemoteGraph.class)
-public class RemoteGraphTranslatorProcessComputerTest {
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessStandardTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessStandardTest.java
deleted file mode 100644
index d3963c1..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/process/RemoteGraphTranslatorProcessStandardTest.java
+++ /dev/null
@@ -1,34 +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.remote.process;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.driver.remote.RemoteGraphTranslatorProvider;
-import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
-import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(ProcessStandardSuite.class)
-@GraphProviderClass(provider = RemoteGraphTranslatorProvider.class, graph = RemoteGraph.class)
-public class RemoteGraphTranslatorProcessStandardTest {
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-variant/pom.xml b/gremlin-variant/pom.xml
deleted file mode 100644
index 8380237..0000000
--- a/gremlin-variant/pom.xml
+++ /dev/null
@@ -1,334 +0,0 @@
-<?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-variant</artifactId>
- <name>Apache TinkerPop :: Gremlin Language Variant</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-variant/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonGenerator.groovy b/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonGenerator.groovy
deleted file mode 100644
index 9e79739..0000000
--- a/gremlin-variant/src/main/groovy/org/apache/tinkerpop/gremlin/python/GremlinPythonGenerator.groovy
+++ /dev/null
@@ -1,314 +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.python
-
-import org.apache.tinkerpop.gremlin.process.computer.Computer
-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.process.traversal.strategy.verification.ReadOnlyStrategy
-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 GremlinPythonGenerator {
-
- 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-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
deleted file mode 100644
index c7bc40a..0000000
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
+++ /dev/null
@@ -1,33 +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.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;
- }
- GremlinPythonGenerator.create(dest);
- }
-}
[2/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.
Posted by ok...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_python/gremlin_python.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_python/gremlin_python.py b/gremlin-variant/src/main/jython/gremlin_python/gremlin_python.py
deleted file mode 100644
index ab478d0..0000000
--- a/gremlin-variant/src/main/jython/gremlin_python/gremlin_python.py
+++ /dev/null
@@ -1,1832 +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.
-'''
-from collections import OrderedDict
-from aenum import Enum
-statics = OrderedDict()
-
-
-globalTranslator = None
-
-
-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 + "]"
- def E(self, *args):
- traversal = PythonGraphTraversal(self.translator, self.remote_connection)
- traversal.translator.addSpawnStep(traversal, "E", *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
- def V(self, *args):
- traversal = PythonGraphTraversal(self.translator, self.remote_connection)
- traversal.translator.addSpawnStep(traversal, "V", *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
- def addV(self, *args):
- traversal = PythonGraphTraversal(self.translator, self.remote_connection)
- traversal.translator.addSpawnStep(traversal, "addV", *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
- def inject(self, *args):
- traversal = PythonGraphTraversal(self.translator, self.remote_connection)
- traversal.translator.addSpawnStep(traversal, "inject", *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
- def withBulk(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withBulk", *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
- def withComputer(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withComputer", *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
- def withPath(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withPath", *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
- def withSack(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withSack", *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
- def withSideEffect(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withSideEffect", *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
- def withStrategies(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withStrategies", *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
- def withTranslator(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withTranslator", *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
- def withoutStrategies(self, *args):
- source = PythonGraphTraversalSource(self.translator, self.remote_connection)
- source.translator.addSource(source, "withoutStrategies", *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
-
-
-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
- def V(self, *args):
- self.translator.addStep(self, "V", *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
- def _and(self, *args):
- self.translator.addStep(self, "_and", *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
- def _as(self, *args):
- self.translator.addStep(self, "_as", *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
- def _from(self, *args):
- self.translator.addStep(self, "_from", *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
- def _in(self, *args):
- self.translator.addStep(self, "_in", *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
- def _is(self, *args):
- self.translator.addStep(self, "_is", *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
- def _not(self, *args):
- self.translator.addStep(self, "_not", *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
- def _or(self, *args):
- self.translator.addStep(self, "_or", *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
- def addE(self, *args):
- self.translator.addStep(self, "addE", *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
- def addInE(self, *args):
- self.translator.addStep(self, "addInE", *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
- def addOutE(self, *args):
- self.translator.addStep(self, "addOutE", *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
- def addV(self, *args):
- self.translator.addStep(self, "addV", *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
- def aggregate(self, *args):
- self.translator.addStep(self, "aggregate", *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
- def asAdmin(self, *args):
- self.translator.addStep(self, "asAdmin", *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
- def barrier(self, *args):
- self.translator.addStep(self, "barrier", *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
- def both(self, *args):
- self.translator.addStep(self, "both", *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
- def bothE(self, *args):
- self.translator.addStep(self, "bothE", *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
- def bothV(self, *args):
- self.translator.addStep(self, "bothV", *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
- def branch(self, *args):
- self.translator.addStep(self, "branch", *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
- def by(self, *args):
- self.translator.addStep(self, "by", *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
- def cap(self, *args):
- self.translator.addStep(self, "cap", *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
- def choose(self, *args):
- self.translator.addStep(self, "choose", *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
- def coalesce(self, *args):
- self.translator.addStep(self, "coalesce", *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
- def coin(self, *args):
- self.translator.addStep(self, "coin", *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
- def constant(self, *args):
- self.translator.addStep(self, "constant", *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
- def count(self, *args):
- self.translator.addStep(self, "count", *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
- def cyclicPath(self, *args):
- self.translator.addStep(self, "cyclicPath", *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
- def dedup(self, *args):
- self.translator.addStep(self, "dedup", *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
- def drop(self, *args):
- self.translator.addStep(self, "drop", *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
- def emit(self, *args):
- self.translator.addStep(self, "emit", *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
- def filter(self, *args):
- self.translator.addStep(self, "filter", *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
- def flatMap(self, *args):
- self.translator.addStep(self, "flatMap", *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
- def fold(self, *args):
- self.translator.addStep(self, "fold", *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
- def group(self, *args):
- self.translator.addStep(self, "group", *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
- def groupCount(self, *args):
- self.translator.addStep(self, "groupCount", *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
- def groupV3d0(self, *args):
- self.translator.addStep(self, "groupV3d0", *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
- def has(self, *args):
- self.translator.addStep(self, "has", *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
- def hasId(self, *args):
- self.translator.addStep(self, "hasId", *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
- def hasKey(self, *args):
- self.translator.addStep(self, "hasKey", *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
- def hasLabel(self, *args):
- self.translator.addStep(self, "hasLabel", *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
- def hasNot(self, *args):
- self.translator.addStep(self, "hasNot", *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
- def hasValue(self, *args):
- self.translator.addStep(self, "hasValue", *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
- def id(self, *args):
- self.translator.addStep(self, "id", *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
- def identity(self, *args):
- self.translator.addStep(self, "identity", *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
- def inE(self, *args):
- self.translator.addStep(self, "inE", *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
- def inV(self, *args):
- self.translator.addStep(self, "inV", *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
- def inject(self, *args):
- self.translator.addStep(self, "inject", *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
- def iterate(self, *args):
- self.translator.addStep(self, "iterate", *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
- def key(self, *args):
- self.translator.addStep(self, "key", *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
- def label(self, *args):
- self.translator.addStep(self, "label", *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
- def limit(self, *args):
- self.translator.addStep(self, "limit", *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
- def local(self, *args):
- self.translator.addStep(self, "local", *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
- def loops(self, *args):
- self.translator.addStep(self, "loops", *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
- def map(self, *args):
- self.translator.addStep(self, "map", *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
- def mapKeys(self, *args):
- self.translator.addStep(self, "mapKeys", *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
- def mapValues(self, *args):
- self.translator.addStep(self, "mapValues", *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
- def match(self, *args):
- self.translator.addStep(self, "match", *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
- def max(self, *args):
- self.translator.addStep(self, "max", *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
- def mean(self, *args):
- self.translator.addStep(self, "mean", *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
- def min(self, *args):
- self.translator.addStep(self, "min", *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
- def option(self, *args):
- self.translator.addStep(self, "option", *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
- def optional(self, *args):
- self.translator.addStep(self, "optional", *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
- def order(self, *args):
- self.translator.addStep(self, "order", *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
- def otherV(self, *args):
- self.translator.addStep(self, "otherV", *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
- def out(self, *args):
- self.translator.addStep(self, "out", *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
- def outE(self, *args):
- self.translator.addStep(self, "outE", *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
- def outV(self, *args):
- self.translator.addStep(self, "outV", *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
- def pageRank(self, *args):
- self.translator.addStep(self, "pageRank", *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
- def path(self, *args):
- self.translator.addStep(self, "path", *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
- def peerPressure(self, *args):
- self.translator.addStep(self, "peerPressure", *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
- def profile(self, *args):
- self.translator.addStep(self, "profile", *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
- def program(self, *args):
- self.translator.addStep(self, "program", *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
- def project(self, *args):
- self.translator.addStep(self, "project", *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
- def properties(self, *args):
- self.translator.addStep(self, "properties", *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
- def property(self, *args):
- self.translator.addStep(self, "property", *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
- def propertyMap(self, *args):
- self.translator.addStep(self, "propertyMap", *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
- def range(self, *args):
- self.translator.addStep(self, "range", *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
- def repeat(self, *args):
- self.translator.addStep(self, "repeat", *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
- def sack(self, *args):
- self.translator.addStep(self, "sack", *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
- def sample(self, *args):
- self.translator.addStep(self, "sample", *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
- def select(self, *args):
- self.translator.addStep(self, "select", *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
- def sideEffect(self, *args):
- self.translator.addStep(self, "sideEffect", *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
- def simplePath(self, *args):
- self.translator.addStep(self, "simplePath", *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
- def store(self, *args):
- self.translator.addStep(self, "store", *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
- def subgraph(self, *args):
- self.translator.addStep(self, "subgraph", *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
- def sum(self, *args):
- self.translator.addStep(self, "sum", *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
- def tail(self, *args):
- self.translator.addStep(self, "tail", *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
- def timeLimit(self, *args):
- self.translator.addStep(self, "timeLimit", *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
- def times(self, *args):
- self.translator.addStep(self, "times", *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
- def to(self, *args):
- self.translator.addStep(self, "to", *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
- def toE(self, *args):
- self.translator.addStep(self, "toE", *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
- def toV(self, *args):
- self.translator.addStep(self, "toV", *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
- def tree(self, *args):
- self.translator.addStep(self, "tree", *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
- def unfold(self, *args):
- self.translator.addStep(self, "unfold", *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
- def union(self, *args):
- self.translator.addStep(self, "union", *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
- def until(self, *args):
- self.translator.addStep(self, "until", *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
- def value(self, *args):
- self.translator.addStep(self, "value", *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
- def valueMap(self, *args):
- self.translator.addStep(self, "valueMap", *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
- def values(self, *args):
- self.translator.addStep(self, "values", *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
- def where(self, *args):
- self.translator.addStep(self, "where", *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
-
-
-class __(object):
- @staticmethod
- def V(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).V(*args)
- @staticmethod
- def __(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).__(*args)
- @staticmethod
- def _and(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._and(*args)
- @staticmethod
- def _as(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._as(*args)
- @staticmethod
- def _in(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._in(*args)
- @staticmethod
- def _is(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._is(*args)
- @staticmethod
- def _not(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._not(*args)
- @staticmethod
- def _or(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator())._or(*args)
- @staticmethod
- def addE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addE(*args)
- @staticmethod
- def addInE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addInE(*args)
- @staticmethod
- def addOutE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addOutE(*args)
- @staticmethod
- def addV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).addV(*args)
- @staticmethod
- def aggregate(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).aggregate(*args)
- @staticmethod
- def barrier(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).barrier(*args)
- @staticmethod
- def both(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).both(*args)
- @staticmethod
- def bothE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).bothE(*args)
- @staticmethod
- def bothV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).bothV(*args)
- @staticmethod
- def branch(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).branch(*args)
- @staticmethod
- def cap(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).cap(*args)
- @staticmethod
- def choose(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).choose(*args)
- @staticmethod
- def coalesce(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).coalesce(*args)
- @staticmethod
- def coin(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).coin(*args)
- @staticmethod
- def constant(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).constant(*args)
- @staticmethod
- def count(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).count(*args)
- @staticmethod
- def cyclicPath(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).cyclicPath(*args)
- @staticmethod
- def dedup(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).dedup(*args)
- @staticmethod
- def drop(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).drop(*args)
- @staticmethod
- def emit(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).emit(*args)
- @staticmethod
- def filter(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).filter(*args)
- @staticmethod
- def flatMap(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).flatMap(*args)
- @staticmethod
- def fold(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).fold(*args)
- @staticmethod
- def group(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).group(*args)
- @staticmethod
- def groupCount(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).groupCount(*args)
- @staticmethod
- def groupV3d0(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).groupV3d0(*args)
- @staticmethod
- def has(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).has(*args)
- @staticmethod
- def hasId(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasId(*args)
- @staticmethod
- def hasKey(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasKey(*args)
- @staticmethod
- def hasLabel(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasLabel(*args)
- @staticmethod
- def hasNot(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasNot(*args)
- @staticmethod
- def hasValue(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).hasValue(*args)
- @staticmethod
- def id(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).id(*args)
- @staticmethod
- def identity(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).identity(*args)
- @staticmethod
- def inE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inE(*args)
- @staticmethod
- def inV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inV(*args)
- @staticmethod
- def inject(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).inject(*args)
- @staticmethod
- def key(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).key(*args)
- @staticmethod
- def label(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).label(*args)
- @staticmethod
- def limit(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).limit(*args)
- @staticmethod
- def local(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).local(*args)
- @staticmethod
- def loops(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).loops(*args)
- @staticmethod
- def map(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).map(*args)
- @staticmethod
- def mapKeys(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mapKeys(*args)
- @staticmethod
- def mapValues(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mapValues(*args)
- @staticmethod
- def match(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).match(*args)
- @staticmethod
- def max(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).max(*args)
- @staticmethod
- def mean(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).mean(*args)
- @staticmethod
- def min(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).min(*args)
- @staticmethod
- def optional(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).optional(*args)
- @staticmethod
- def order(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).order(*args)
- @staticmethod
- def otherV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).otherV(*args)
- @staticmethod
- def out(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).out(*args)
- @staticmethod
- def outE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).outE(*args)
- @staticmethod
- def outV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).outV(*args)
- @staticmethod
- def path(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).path(*args)
- @staticmethod
- def project(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).project(*args)
- @staticmethod
- def properties(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).properties(*args)
- @staticmethod
- def property(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).property(*args)
- @staticmethod
- def propertyMap(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).propertyMap(*args)
- @staticmethod
- def range(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).range(*args)
- @staticmethod
- def repeat(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).repeat(*args)
- @staticmethod
- def sack(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sack(*args)
- @staticmethod
- def sample(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sample(*args)
- @staticmethod
- def select(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).select(*args)
- @staticmethod
- def sideEffect(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sideEffect(*args)
- @staticmethod
- def simplePath(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).simplePath(*args)
- @staticmethod
- def start(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).start(*args)
- @staticmethod
- def store(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).store(*args)
- @staticmethod
- def subgraph(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).subgraph(*args)
- @staticmethod
- def sum(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).sum(*args)
- @staticmethod
- def tail(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).tail(*args)
- @staticmethod
- def timeLimit(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).timeLimit(*args)
- @staticmethod
- def times(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).times(*args)
- @staticmethod
- def to(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).to(*args)
- @staticmethod
- def toE(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).toE(*args)
- @staticmethod
- def toV(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).toV(*args)
- @staticmethod
- def tree(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).tree(*args)
- @staticmethod
- def unfold(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).unfold(*args)
- @staticmethod
- def union(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).union(*args)
- @staticmethod
- def until(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).until(*args)
- @staticmethod
- def value(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).value(*args)
- @staticmethod
- def valueMap(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).valueMap(*args)
- @staticmethod
- def values(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).values(*args)
- @staticmethod
- def where(*args):
- return PythonGraphTraversal(globalTranslator.getAnonymousTraversalTranslator()).where(*args)
-
-
-def V(*args):
- return __.V(*args)
-
-statics['V'] = V
-def _and(*args):
- return __._and(*args)
-
-statics['_and'] = _and
-def _as(*args):
- return __._as(*args)
-
-statics['_as'] = _as
-def _in(*args):
- return __._in(*args)
-
-statics['_in'] = _in
-def _is(*args):
- return __._is(*args)
-
-statics['_is'] = _is
-def _not(*args):
- return __._not(*args)
-
-statics['_not'] = _not
-def _or(*args):
- return __._or(*args)
-
-statics['_or'] = _or
-def addE(*args):
- return __.addE(*args)
-
-statics['addE'] = addE
-def addInE(*args):
- return __.addInE(*args)
-
-statics['addInE'] = addInE
-def addOutE(*args):
- return __.addOutE(*args)
-
-statics['addOutE'] = addOutE
-def addV(*args):
- return __.addV(*args)
-
-statics['addV'] = addV
-def aggregate(*args):
- return __.aggregate(*args)
-
-statics['aggregate'] = aggregate
-def barrier(*args):
- return __.barrier(*args)
-
-statics['barrier'] = barrier
-def both(*args):
- return __.both(*args)
-
-statics['both'] = both
-def bothE(*args):
- return __.bothE(*args)
-
-statics['bothE'] = bothE
-def bothV(*args):
- return __.bothV(*args)
-
-statics['bothV'] = bothV
-def branch(*args):
- return __.branch(*args)
-
-statics['branch'] = branch
-def cap(*args):
- return __.cap(*args)
-
-statics['cap'] = cap
-def choose(*args):
- return __.choose(*args)
-
-statics['choose'] = choose
-def coalesce(*args):
- return __.coalesce(*args)
-
-statics['coalesce'] = coalesce
-def coin(*args):
- return __.coin(*args)
-
-statics['coin'] = coin
-def constant(*args):
- return __.constant(*args)
-
-statics['constant'] = constant
-def count(*args):
- return __.count(*args)
-
-statics['count'] = count
-def cyclicPath(*args):
- return __.cyclicPath(*args)
-
-statics['cyclicPath'] = cyclicPath
-def dedup(*args):
- return __.dedup(*args)
-
-statics['dedup'] = dedup
-def drop(*args):
- return __.drop(*args)
-
-statics['drop'] = drop
-def emit(*args):
- return __.emit(*args)
-
-statics['emit'] = emit
-def filter(*args):
- return __.filter(*args)
-
-statics['filter'] = filter
-def flatMap(*args):
- return __.flatMap(*args)
-
-statics['flatMap'] = flatMap
-def fold(*args):
- return __.fold(*args)
-
-statics['fold'] = fold
-def group(*args):
- return __.group(*args)
-
-statics['group'] = group
-def groupCount(*args):
- return __.groupCount(*args)
-
-statics['groupCount'] = groupCount
-def groupV3d0(*args):
- return __.groupV3d0(*args)
-
-statics['groupV3d0'] = groupV3d0
-def has(*args):
- return __.has(*args)
-
-statics['has'] = has
-def hasId(*args):
- return __.hasId(*args)
-
-statics['hasId'] = hasId
-def hasKey(*args):
- return __.hasKey(*args)
-
-statics['hasKey'] = hasKey
-def hasLabel(*args):
- return __.hasLabel(*args)
-
-statics['hasLabel'] = hasLabel
-def hasNot(*args):
- return __.hasNot(*args)
-
-statics['hasNot'] = hasNot
-def hasValue(*args):
- return __.hasValue(*args)
-
-statics['hasValue'] = hasValue
-def id(*args):
- return __.id(*args)
-
-statics['id'] = id
-def identity(*args):
- return __.identity(*args)
-
-statics['identity'] = identity
-def inE(*args):
- return __.inE(*args)
-
-statics['inE'] = inE
-def inV(*args):
- return __.inV(*args)
-
-statics['inV'] = inV
-def inject(*args):
- return __.inject(*args)
-
-statics['inject'] = inject
-def key(*args):
- return __.key(*args)
-
-statics['key'] = key
-def label(*args):
- return __.label(*args)
-
-statics['label'] = label
-def limit(*args):
- return __.limit(*args)
-
-statics['limit'] = limit
-def local(*args):
- return __.local(*args)
-
-statics['local'] = local
-def loops(*args):
- return __.loops(*args)
-
-statics['loops'] = loops
-def map(*args):
- return __.map(*args)
-
-statics['map'] = map
-def mapKeys(*args):
- return __.mapKeys(*args)
-
-statics['mapKeys'] = mapKeys
-def mapValues(*args):
- return __.mapValues(*args)
-
-statics['mapValues'] = mapValues
-def match(*args):
- return __.match(*args)
-
-statics['match'] = match
-def max(*args):
- return __.max(*args)
-
-statics['max'] = max
-def mean(*args):
- return __.mean(*args)
-
-statics['mean'] = mean
-def min(*args):
- return __.min(*args)
-
-statics['min'] = min
-def optional(*args):
- return __.optional(*args)
-
-statics['optional'] = optional
-def order(*args):
- return __.order(*args)
-
-statics['order'] = order
-def otherV(*args):
- return __.otherV(*args)
-
-statics['otherV'] = otherV
-def out(*args):
- return __.out(*args)
-
-statics['out'] = out
-def outE(*args):
- return __.outE(*args)
-
-statics['outE'] = outE
-def outV(*args):
- return __.outV(*args)
-
-statics['outV'] = outV
-def path(*args):
- return __.path(*args)
-
-statics['path'] = path
-def project(*args):
- return __.project(*args)
-
-statics['project'] = project
-def properties(*args):
- return __.properties(*args)
-
-statics['properties'] = properties
-def property(*args):
- return __.property(*args)
-
-statics['property'] = property
-def propertyMap(*args):
- return __.propertyMap(*args)
-
-statics['propertyMap'] = propertyMap
-def range(*args):
- return __.range(*args)
-
-statics['range'] = range
-def repeat(*args):
- return __.repeat(*args)
-
-statics['repeat'] = repeat
-def sack(*args):
- return __.sack(*args)
-
-statics['sack'] = sack
-def sample(*args):
- return __.sample(*args)
-
-statics['sample'] = sample
-def select(*args):
- return __.select(*args)
-
-statics['select'] = select
-def sideEffect(*args):
- return __.sideEffect(*args)
-
-statics['sideEffect'] = sideEffect
-def simplePath(*args):
- return __.simplePath(*args)
-
-statics['simplePath'] = simplePath
-def start(*args):
- return __.start(*args)
-
-statics['start'] = start
-def store(*args):
- return __.store(*args)
-
-statics['store'] = store
-def subgraph(*args):
- return __.subgraph(*args)
-
-statics['subgraph'] = subgraph
-def sum(*args):
- return __.sum(*args)
-
-statics['sum'] = sum
-def tail(*args):
- return __.tail(*args)
-
-statics['tail'] = tail
-def timeLimit(*args):
- return __.timeLimit(*args)
-
-statics['timeLimit'] = timeLimit
-def times(*args):
- return __.times(*args)
-
-statics['times'] = times
-def to(*args):
- return __.to(*args)
-
-statics['to'] = to
-def toE(*args):
- return __.toE(*args)
-
-statics['toE'] = toE
-def toV(*args):
- return __.toV(*args)
-
-statics['toV'] = toV
-def tree(*args):
- return __.tree(*args)
-
-statics['tree'] = tree
-def unfold(*args):
- return __.unfold(*args)
-
-statics['unfold'] = unfold
-def union(*args):
- return __.union(*args)
-
-statics['union'] = union
-def until(*args):
- return __.until(*args)
-
-statics['until'] = until
-def value(*args):
- return __.value(*args)
-
-statics['value'] = value
-def valueMap(*args):
- return __.valueMap(*args)
-
-statics['valueMap'] = valueMap
-def values(*args):
- return __.values(*args)
-
-statics['values'] = values
-def where(*args):
- return __.where(*args)
-
-statics['where'] = where
-
-
-Cardinality = Enum('Cardinality', 'single list set')
-
-statics['single'] = Cardinality.single
-statics['list'] = Cardinality.list
-statics['set'] = Cardinality.set
-
-Column = Enum('Column', 'keys values')
-
-statics['keys'] = Column.keys
-statics['values'] = Column.values
-
-Direction = Enum('Direction', 'OUT IN BOTH')
-
-statics['OUT'] = Direction.OUT
-statics['IN'] = Direction.IN
-statics['BOTH'] = Direction.BOTH
-
-Operator = Enum('Operator', 'sum minus mult div min max assign _and _or addAll sumLong')
-
-statics['sum'] = Operator.sum
-statics['minus'] = Operator.minus
-statics['mult'] = Operator.mult
-statics['div'] = Operator.div
-statics['min'] = Operator.min
-statics['max'] = Operator.max
-statics['assign'] = Operator.assign
-statics['_and'] = Operator._and
-statics['_or'] = Operator._or
-statics['addAll'] = Operator.addAll
-statics['sumLong'] = Operator.sumLong
-
-Order = Enum('Order', 'incr decr keyIncr valueIncr keyDecr valueDecr shuffle')
-
-statics['incr'] = Order.incr
-statics['decr'] = Order.decr
-statics['keyIncr'] = Order.keyIncr
-statics['valueIncr'] = Order.valueIncr
-statics['keyDecr'] = Order.keyDecr
-statics['valueDecr'] = Order.valueDecr
-statics['shuffle'] = Order.shuffle
-
-Pop = Enum('Pop', 'first last all')
-
-statics['first'] = Pop.first
-statics['last'] = Pop.last
-statics['all'] = Pop.all
-
-Barrier = Enum('Barrier', 'normSack')
-
-statics['normSack'] = Barrier.normSack
-
-Scope = Enum('Scope', '_global local')
-
-statics['_global'] = Scope._global
-statics['local'] = Scope.local
-
-T = Enum('T', 'label id key value')
-
-statics['label'] = T.label
-statics['id'] = T.id
-statics['key'] = T.key
-statics['value'] = T.value
-
-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)
-
-class Raw(object):
- def __init__(self, value):
- self.value = value
-
- def __str__(self):
- return str(self.value)
-
-class P(object):
- def __init__(self, operator, value, other=None):
- self.operator = operator
- self.value = value
- self.other = other
- @staticmethod
- def _not(*args):
- return P("not", *args)
- @staticmethod
- def between(*args):
- return P("between", *args)
- @staticmethod
- def eq(*args):
- return P("eq", *args)
- @staticmethod
- def gt(*args):
- return P("gt", *args)
- @staticmethod
- def gte(*args):
- return P("gte", *args)
- @staticmethod
- def inside(*args):
- return P("inside", *args)
- @staticmethod
- def lt(*args):
- return P("lt", *args)
- @staticmethod
- def lte(*args):
- return P("lte", *args)
- @staticmethod
- def negate(*args):
- return P("negate", *args)
- @staticmethod
- def neq(*args):
- return P("neq", *args)
- @staticmethod
- def outside(*args):
- return P("outside", *args)
- @staticmethod
- def test(*args):
- return P("test", *args)
- @staticmethod
- def within(*args):
- return P("within", *args)
- @staticmethod
- def without(*args):
- return P("without", *args)
- def _and(self, arg):
- return P("_and", arg, self)
- def _or(self, arg):
- return P("_or", arg, self)
-
-def _and(*args):
- return P._and(*args)
-
-statics['_and'] = _and
-def _not(*args):
- return P._not(*args)
-
-statics['_not'] = _not
-def _or(*args):
- return P._or(*args)
-
-statics['_or'] = _or
-def between(*args):
- return P.between(*args)
-
-statics['between'] = between
-def eq(*args):
- return P.eq(*args)
-
-statics['eq'] = eq
-def gt(*args):
- return P.gt(*args)
-
-statics['gt'] = gt
-def gte(*args):
- return P.gte(*args)
-
-statics['gte'] = gte
-def inside(*args):
- return P.inside(*args)
-
-statics['inside'] = inside
-def lt(*args):
- return P.lt(*args)
-
-statics['lt'] = lt
-def lte(*args):
- return P.lte(*args)
-
-statics['lte'] = lte
-def negate(*args):
- return P.negate(*args)
-
-statics['negate'] = negate
-def neq(*args):
- return P.neq(*args)
-
-statics['neq'] = neq
-def outside(*args):
- return P.outside(*args)
-
-statics['outside'] = outside
-def test(*args):
- return P.test(*args)
-
-statics['test'] = test
-def within(*args):
- return P.within(*args)
-
-statics['within'] = within
-def without(*args):
- return P.without(*args)
-
-statics['without'] = without
-
-statics = OrderedDict(reversed(list(statics.items())))
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_python/groovy_translator.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_python/groovy_translator.py b/gremlin-variant/src/main/jython/gremlin_python/groovy_translator.py
deleted file mode 100644
index 2cd60be..0000000
--- a/gremlin-variant/src/main/jython/gremlin_python/groovy_translator.py
+++ /dev/null
@@ -1,121 +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.
-'''
-
-import sys
-from aenum import Enum
-
-from gremlin_python import P
-from gremlin_python import Raw
-from gremlin_python import RawExpression
-from translator import Translator
-
-if sys.version_info.major > 2:
- long = int
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-methodMap = {"_global": "global", "_as": "as", "_in": "in", "_and": "and", "_or": "or", "_is": "is", "_not": "not",
- "_from": "from"}
-
-enumMap = {"Cardinality": "VertexProperty.Cardinality", "Barrier": "SackFunctions.Barrier"}
-
-
-class GroovyTranslator(Translator):
- def __init__(self, alias, source_language="python", target_language="gremlin-groovy"):
- Translator.__init__(self, alias, source_language, target_language)
-
- def addStep(self, traversal, step_name, *args):
- self.traversal_script = self.traversal_script + "." + GroovyTranslator.mapMethod(
- step_name) + "(" + GroovyTranslator.stringify(*args) + ")"
-
- def addSpawnStep(self, traversal, step_name, *args):
- newTranslator = GroovyTranslator(self.alias, self.source_language)
- newTranslator.traversal_script = self.traversal_script
- newTranslator.traversal_script = newTranslator.traversal_script + "." + GroovyTranslator.mapMethod(
- step_name) + "(" + GroovyTranslator.stringify(*args) + ")"
- traversal.translator = newTranslator
-
- def addSource(self, traversal_source, source_name, *args):
- newTranslator = GroovyTranslator(self.alias, self.source_language)
- newTranslator.traversal_script = self.traversal_script
- newTranslator.traversal_script = newTranslator.traversal_script + "." + GroovyTranslator.mapMethod(
- source_name) + "(" + GroovyTranslator.stringify(*args) + ")"
- traversal_source.translator = newTranslator
-
- def getAnonymousTraversalTranslator(self):
- return GroovyTranslator("__", self.source_language)
-
- ### HELPER METHODS ###
-
- @staticmethod
- def mapMethod(method):
- if (method in methodMap):
- return methodMap[method]
- else:
- return method
-
- @staticmethod
- def mapEnum(enum):
- if (enum in enumMap):
- return enumMap[enum]
- else:
- return enum
-
- @staticmethod
- def stringOrObject(arg):
- if isinstance(arg, str):
- return "\"" + arg + "\""
- elif isinstance(arg, bool):
- return str(arg).lower()
- elif isinstance(arg, long):
- return str(arg) + "L"
- elif isinstance(arg, float):
- return str(arg) + "f"
- elif isinstance(arg, Enum): # Column, Order, Direction, Scope, T, etc.
- return GroovyTranslator.mapEnum(type(arg).__name__) + "." + GroovyTranslator.mapMethod(str(arg.name))
- elif isinstance(arg, P):
- if arg.other is None:
- return "P." + GroovyTranslator.mapMethod(arg.operator) + "(" + GroovyTranslator.stringOrObject(
- arg.value) + ")"
- else:
- return GroovyTranslator.stringOrObject(arg.other) + "." + GroovyTranslator.mapMethod(
- arg.operator) + "(" + GroovyTranslator.stringOrObject(arg.value) + ")"
- elif callable(arg): # closures
- lambdaString = arg().strip()
- if lambdaString.startswith("{"):
- return lambdaString
- else:
- return "{" + lambdaString + "}"
- elif isinstance(arg, tuple) and 2 == len(arg) and isinstance(arg[0], str): # bindings
- return arg[0]
- elif isinstance(arg, RawExpression):
- return "".join(GroovyTranslator.stringOrObject(i) for i in arg.parts)
- elif isinstance(arg, Raw):
- return str(arg)
- else:
- return str(arg)
-
- @staticmethod
- def stringify(*args):
- if len(args) == 0:
- return ""
- elif len(args) == 1:
- return GroovyTranslator.stringOrObject(args[0])
- else:
- return ", ".join(GroovyTranslator.stringOrObject(i) for i in args)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_python/translator.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_python/translator.py b/gremlin-variant/src/main/jython/gremlin_python/translator.py
deleted file mode 100644
index bf3a83a..0000000
--- a/gremlin-variant/src/main/jython/gremlin_python/translator.py
+++ /dev/null
@@ -1,45 +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.
-'''
-from abc import abstractmethod
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-
-class Translator(object):
- def __init__(self, alias, source_language, target_language):
- self.alias = alias
- self.source_language = source_language
- self.target_language = target_language
- self.traversal_script = alias
-
- @abstractmethod
- def addStep(self, traversal, step_name, *args):
- return
-
- @abstractmethod
- def addSpawnStep(self, traversal, step_name, *args):
- return
-
- @abstractmethod
- def addSource(self, traversal_source, source_name, *args):
- return
-
- @abstractmethod
- def getAnonymousTraversalTranslator(self):
- return Translator(self.alias, self.source_language, self.target_language)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_rest_driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_rest_driver/__init__.py b/gremlin-variant/src/main/jython/gremlin_rest_driver/__init__.py
deleted file mode 100644
index 8ae13f8..0000000
--- a/gremlin-variant/src/main/jython/gremlin_rest_driver/__init__.py
+++ /dev/null
@@ -1,21 +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.
-'''
-from gremlin_rest_driver import RESTRemoteConnection
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py b/gremlin-variant/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
deleted file mode 100644
index b265752..0000000
--- a/gremlin-variant/src/main/jython/gremlin_rest_driver/gremlin_rest_driver.py
+++ /dev/null
@@ -1,41 +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.
-'''
-import json
-import requests
-from gremlin_driver import RemoteConnection
-from gremlin_driver import Traverser
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-
-class RESTRemoteConnection(RemoteConnection):
- def __init__(self, url):
- RemoteConnection.__init__(self, url)
-
- def __repr__(self):
- return "RESTRemoteConnection[" + self.url + "]"
-
- def submit(self, target_language, script, bindings):
- response = requests.post(self.url, data=json.dumps({"gremlin": script, "language": target_language, "bindings": bindings}))
- if response.status_code != requests.codes.ok:
- raise BaseException(response.text)
- results = []
- for x in response.json()['result']['data']:
- results.append(Traverser(x, 1))
- return iter(results)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/setup.cfg
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/setup.cfg b/gremlin-variant/src/main/jython/setup.cfg
deleted file mode 100644
index de959fe..0000000
--- a/gremlin-variant/src/main/jython/setup.cfg
+++ /dev/null
@@ -1,18 +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.
-[bdist_wheel]
-universal=1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/setup.py b/gremlin-variant/src/main/jython/setup.py
deleted file mode 100644
index 05f1dc3..0000000
--- a/gremlin-variant/src/main/jython/setup.py
+++ /dev/null
@@ -1,58 +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.
-'''
-import os
-import time
-import codecs
-
-from setuptools import setup
-
-# Folder containing the setup.py
-root = os.path.dirname(os.path.abspath(__file__))
-
-# Path to __version__ module
-version_file = os.path.join(root, '.', '__version__.py')
-
-# Check if this is a source distribution.
-# If not create the __version__ module containing the version
-if not os.path.exists(os.path.join(root, 'PKG-INFO')):
- timestamp = int(os.getenv('TIMESTAMP', time.time() * 1000)) / 1000
- fd = codecs.open(version_file, 'w', 'utf-8')
- fd.write("'''")
- fd.write(__doc__)
- fd.write("'''\n")
- fd.write('version = %r\n' % os.getenv('VERSION', '?').replace('-SNAPSHOT', '.dev-%d' % timestamp))
- fd.write('timestamp = %d\n' % timestamp)
- fd.close()
-# Load version
-import __version__
-version = __version__.version
-
-setup(
- name='gremlinpython',
- version=version,
- packages=['gremlin_driver','gremlin_python', 'gremlin_rest_driver'],
- license='Apache 2',
- url='http://tinkerpop.apache.org',
- description='Gremlin Language Variant for Apache TinkerPop - Gremlin',
- long_description=open("README").read(),
- install_requires=[
- 'aenum',
- 'requests'
- ]
-)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/VariantGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/VariantGraphProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/VariantGraphProvider.java
deleted file mode 100644
index 8545dff..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/VariantGraphProvider.java
+++ /dev/null
@@ -1,128 +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;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.AbstractGraphProvider;
-import org.apache.tinkerpop.gremlin.LoadGraphWith;
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest;
-import org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class VariantGraphProvider extends AbstractGraphProvider {
-
- private static Set<String> SKIP_TESTS = new HashSet<>(Arrays.asList(
- "testProfileStrategyCallback",
- "testProfileStrategyCallbackSideEffect",
- "g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX",
- "g_V_both_hasLabelXpersonX_order_byXage_decrX_name",
- "g_VX1X_out_injectXv2X_name",
- "shouldSupportGraphFilter",
- "shouldNeverPropagateANoBulkTraverser",
- "shouldNeverPropagateANullValuedTraverser",
- "shouldTraversalResetProperly",
- "shouldHidePartitionKeyForValues",
- ProgramTest.Traversals.class.getCanonicalName(),
- TraversalInterruptionTest.class.getCanonicalName(),
- TraversalInterruptionComputerTest.class.getCanonicalName(),
- ElementIdStrategyProcessTest.class.getCanonicalName()));
-
- private static final Set<Class> IMPLEMENTATION = new HashSet<Class>() {{
- add(TinkerEdge.class);
- add(TinkerElement.class);
- add(TinkerGraph.class);
- add(TinkerGraphVariables.class);
- add(TinkerProperty.class);
- add(TinkerVertex.class);
- add(TinkerVertexProperty.class);
- }};
-
- @Override
- public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName,
- final LoadGraphWith.GraphData loadGraphWith) {
-
- final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith);
- final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromGraphData(loadGraphWith) : idManager).name();
- return new HashMap<String, Object>() {{
- put(Graph.GRAPH, TinkerGraph.class.getName());
- put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker);
- put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker);
- put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker);
- put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName()));
- if (loadGraphWith == LoadGraphWith.GraphData.CREW)
- put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
- }};
- }
-
- @Override
- public void clear(final Graph graph, final Configuration configuration) throws Exception {
- if (graph != null) graph.close();
- }
-
- @Override
- public Set<Class> getImplementations() {
- return IMPLEMENTATION;
- }
-
- /**
- * Test that load with specific graph data can be configured with a specific id manager as the data type to
- * be used in the test for that graph is known.
- */
- protected TinkerGraph.DefaultIdManager selectIdMakerFromGraphData(final LoadGraphWith.GraphData loadGraphWith) {
- if (null == loadGraphWith) return TinkerGraph.DefaultIdManager.ANY;
- if (loadGraphWith.equals(LoadGraphWith.GraphData.CLASSIC))
- return TinkerGraph.DefaultIdManager.INTEGER;
- else if (loadGraphWith.equals(LoadGraphWith.GraphData.MODERN))
- return TinkerGraph.DefaultIdManager.INTEGER;
- else if (loadGraphWith.equals(LoadGraphWith.GraphData.CREW))
- return TinkerGraph.DefaultIdManager.INTEGER;
- else if (loadGraphWith.equals(LoadGraphWith.GraphData.GRATEFUL))
- return TinkerGraph.DefaultIdManager.INTEGER;
- else
- throw new IllegalStateException(String.format("Need to define a new %s for %s", TinkerGraph.IdManager.class.getName(), loadGraphWith.name()));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49674539/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyComputerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyComputerProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyComputerProvider.java
deleted file mode 100644
index e8e58d5..0000000
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyComputerProvider.java
+++ /dev/null
@@ -1,37 +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.GraphProvider;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@GraphProvider.Descriptor(computer = TinkerGraphComputer.class)
-public class GroovyComputerProvider extends GroovyProvider {
-
- @Override
- public GraphTraversalSource traversal(final Graph graph) {
- return super.traversal(graph).withComputer();
- }
-}
[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.
Posted by ok...@apache.org.
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