added more test cases and better error handling for Gremlin-Python test. Also 
went through the Gremlin-Python docs and tweaked a little here and there. Path 
is lookin' good.


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

Branch: refs/heads/TINKERPOP-1280
Commit: 9050ad1b1d17ac60d260411720f4e46a716dbe64
Parents: 144a7cd
Author: Marko A. Rodriguez <okramma...@gmail.com>
Authored: Tue Sep 13 09:03:41 2016 -0600
Committer: Marko A. Rodriguez <okramma...@gmail.com>
Committed: Tue Sep 13 09:03:41 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                               |  1 +
 docs/src/reference/gremlin-variants.asciidoc     | 12 ++++++------
 docs/src/reference/intro.asciidoc                | 14 +++++++-------
 .../jython/gremlin_python/structure/graph.py     |  4 ++--
 .../main/jython/tests/structure/test_graph.py    | 19 ++++++++++++++++++-
 5 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9050ad1b/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7035b5e..9998a24 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ 
image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.3 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added `Path` to Gremlin-Python with respective GraphSON 2.0 deserializer.
 * Added missing `InetAddress` to GraphSON extension module.
 
 [[release-3-2-2]]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9050ad1b/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc 
b/docs/src/reference/gremlin-variants.asciidoc
index 0673867..bf9df2e 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -118,13 +118,13 @@ $ bin/gremlin-server.sh conf/gremlin-server-modern-py.yaml
 NOTE: The command to use `-i` need only be executed once to gather 
`gremlin-python` dependencies into Gremlin Servers'
 path. Future starts of Gremlin Server will not require that command.
 
-Within the CPython console, it is possible to evaluate the following.
+Within the CPython console, an empty `Graph` is created and a traversal source 
is spawned with `RemoteStrategy`.
 
 [source,python]
 >>> graph = Graph()
 >>> g = 
 >>> graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
 
-When a traversal spawned from the `GraphTraversalSource` above is iterated, 
the traveral's `Bytecode` is sent over the wire
+When a traversal from the `GraphTraversalSource` is iterated, the traversal's 
`Bytecode` is sent over the wire
 via the registered `RemoteConnection`. The bytecode is used to construct the 
equivalent traversal at the remote traversal source.
 Moreover, typically the bytecode is analyzed to determine which language the 
bytecode should be translated to. If the traversal
 does not contain lambdas, the remote location (e.g. Gremlin Server) will 
typically
@@ -138,7 +138,7 @@ RemoteConnection Submission
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 There are various ways to submit a traversal to a `RemoteConnection`. Just as 
in Gremlin-Java, there are various
-"action methods" off of `Traversal`.
+"terminal/action methods" off of `Traversal`.
 
 * `Traversal.next()`
 * `Traversal.nextTraverser()`
@@ -183,7 +183,7 @@ These can be used analogously to how they are used in 
Gremlin-Java.
 
g.V().hasLabel('person').has('age',P.gt(30)).order().by('age',Order.decr).toList()
 ----
 
-Moreover, by importing the `statics` of Gremlin-Python, the class prefixes can 
be removed.
+Moreover, by importing the `statics` of Gremlin-Python, the class prefixes can 
be ommitted.
 
 [source,python]
 >>> statics.load_statics(globals())
@@ -209,7 +209,7 @@ Bindings
 When a traversal bytecode is sent over a `RemoteConnection` (e.g. Gremlin 
Server), it will be translated, compiled, and then executed.
 If the same traversal is sent again, translation and compilation can be 
skipped as the previously compiled version should be cached.
 Many traversals are unique up to some parameterization. For instance, 
`g.V(1).out('created').name` is considered different
-from `g.V(4).out('created').name'` as they are different "string" scripts. 
However, `g.V(x).out('created').name` with bindings of `{x : 1}` and
+from `g.V(4).out('created').name'` as they have different script "string" 
representations. However, `g.V(x).out('created').name` with bindings of `{x : 
1}` and
 `{x : 4}` are considered the same. If a traversal is going to be executed 
repeatedly, but with different parameters, then bindings should be used.
 In Gremlin-Python, bindings are 2-tuples and used as follows.
 
@@ -219,7 +219,7 @@ g.V(('id',1)).out('created').name.toList()
 g.V(('id',4)).out('created').name.toList()
 ----
 
-NOTE: The Gremlin `withBindings()` traversal source step is not needed. This 
is only required
+NOTE: The Gremlin `withBindings()` traversal source step is not needed. 
Typically `withBindings()` is only required
 in statically typed languages where bindings need to have the same typing as 
the `Traversal` API. However, if desired,
 it is possible to use the `withBindings()`-model as Gremlin-Python's 
`Bindings.of()` simply returns a 2-tuple of `(str,object)`
 (see <<connecting-via-remotegraph,`Bindings`>>).

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9050ad1b/docs/src/reference/intro.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/intro.asciidoc 
b/docs/src/reference/intro.asciidoc
index d38e23b..f7a32ce 100644
--- a/docs/src/reference/intro.asciidoc
+++ b/docs/src/reference/intro.asciidoc
@@ -342,17 +342,17 @@ On Gremlin Language Variants
 ----------------------------
 
 Gremlin is written in Java 8. There are various language variants of Gremlin 
such as Gremlin-Groovy (packaged with
-TinkerPop3), link:https://github.com/mpollmeier/gremlin-scala[Gremlin-Scala], 
Gremlin-JavaScript, Gremlin-Clojure
-(known as link:https://github.com/clojurewerkz/ogre[Ogre]), etc. It is best to 
think of Gremlin as a style of graph
-traversing that is not bound to a particular programming language per se. 
Within a programming language familiar to
-the developer, there is a Gremlin variant that they can use that leverages the 
idioms of that language. At minimum,
-a programming language providing a Gremlin implementation must support
+TinkerPop3), Gremlin-Python (packaged with TinkerPop3), 
link:https://github.com/mpollmeier/gremlin-scala[Gremlin-Scala],
+Gremlin-JavaScript, Gremlin-Clojure (known as 
link:https://github.com/clojurewerkz/ogre[Ogre]), etc.
+It is best to think of Gremlin as a style of graph traversing that is not 
bound to a particular programming language per se.
+Within a programming language familiar to the developer, there is a Gremlin 
variant that they can use that leverages
+the idioms of that language. At minimum, a programming language providing a 
Gremlin implementation must support
 link:http://en.wikipedia.org/wiki/Method_chaining[function chaining] (with
 link:http://en.wikipedia.org/wiki/Anonymous_function[lambdas/anonymous 
functions] being a "nice to have" if the
-variant wishes to offer arbitrary computations beyond the provided Gremlin 
steps).
+variants wishes to offer arbitrary computations beyond the provided Gremlin 
steps).
 
 Throughout the documentation, the examples provided are primarily written in 
Gremlin-Groovy. The reason for this is
-the <<gremlin-console,Gremlin Console>> whereby an interactive programming 
environment exists that does not require
+the <<gremlin-console,Gremlin Console>> -- an interactive programming 
environment exists that does not require
 code compilation. For learning TinkerPop3 and interacting with a live graph 
system in an ad hoc manner, the Gremlin
 Console is invaluable. However, for developers interested in working with 
Gremlin-Java, a few Groovy-to-Java patterns
 are presented below.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9050ad1b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
index b60dc65..d77cde1 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
@@ -111,12 +111,12 @@ class Path(object):
                 if key in labels:
                     objects.append(self.objects[i])
             if 0 == len(objects):
-                raise Error("The step with label " + key + " does not exist")
+                raise KeyError("The step with label " + key + " does not 
exist")
             return objects if len(objects) > 1 else objects[0]
         elif isinstance(key, int):
             return self.objects[key]
         else:
-            raise Error("The step with label " + key + " does not exist")
+            raise TypeError("The path access key must be either a string label 
or integer index")
 
     def __len__(self):
         return len(self.objects)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9050ad1b/gremlin-python/src/main/jython/tests/structure/test_graph.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/test_graph.py 
b/gremlin-python/src/main/jython/tests/structure/test_graph.py
index bb0d284..72b4b79 100644
--- a/gremlin-python/src/main/jython/tests/structure/test_graph.py
+++ b/gremlin-python/src/main/jython/tests/structure/test_graph.py
@@ -80,12 +80,29 @@ class TestGraph(TestCase):
         assert path[1] == Vertex(1)
         assert path[2] == "hello"
         assert 3 == len(path)
+        assert "hello" in path
+        assert "goodbye" not in path
+        assert Vertex(1) in path
+        assert Vertex(123) not in path
+        #
         try:
             temp = path[3]
-            raise Exception("Accessing beyond the list index should throw an 
error")
+            raise Exception("Accessing beyond the list index should throw an 
index error")
         except IndexError:
             pass
         #
+        try:
+            temp = path["zz"]
+            raise Exception("Accessing nothing should throw a key error")
+        except KeyError:
+            pass
+        #
+        try:
+            temp = path[1:2]
+            raise Exception("Accessing using slices should throw a type error")
+        except TypeError:
+            pass
+        #
         assert path == path
         assert hash(path) == hash(path)
         path2 = Path([set(["a", "b"]), set(["c", "b"]), set([])], [1, 
Vertex(1), "hello"])

Reply via email to