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/10/12 20:53:31 UTC
[04/10] tinkerpop git commit: simplification in graphson io
simplification in graphson io
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6c4bf0b7
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6c4bf0b7
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6c4bf0b7
Branch: refs/heads/master
Commit: 6c4bf0b71426b7c5cf5f7a34b5eec23b0d9b8b80
Parents: 697e24f
Author: Adam Holmberg <Ad...@datastax.com>
Authored: Fri Sep 30 13:22:37 2016 -0500
Committer: Adam Holmberg <Ad...@datastax.com>
Committed: Mon Oct 10 15:30:44 2016 -0500
----------------------------------------------------------------------
.../jython/gremlin_python/structure/io/graphson.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4bf0b7/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
index 2f81827..b44897a 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
@@ -44,9 +44,9 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
class GraphSONWriter(object):
@staticmethod
def _dictify(obj):
- for key in serializers:
+ for key, serializer in serializers.items():
if isinstance(obj, key):
- return serializers[key]._dictify(obj)
+ return serializer._dictify(obj)
# list and map are treated as normal json objs (could be isolated serializers)
if isinstance(obj, (list, set)):
return [GraphSONWriter._dictify(o) for o in obj]
@@ -64,10 +64,10 @@ class GraphSONReader(object):
@staticmethod
def _objectify(obj):
if isinstance(obj, dict):
- if _SymbolHelper._TYPE in obj:
- type = obj[_SymbolHelper._TYPE]
- if type in deserializers:
- return deserializers[type]._objectify(obj)
+ try:
+ return deserializers[obj[_SymbolHelper._TYPE]]._objectify(obj)
+ except KeyError:
+ pass
# list and map are treated as normal json objs (could be isolated deserializers)
return dict((GraphSONReader._objectify(k), GraphSONReader._objectify(v)) for k, v in obj.items())
elif isinstance(obj, list):
@@ -264,7 +264,6 @@ class _SymbolHelper(object):
object[_SymbolHelper._VALUE] = value
return object
-
serializers = {
Traversal: BytecodeSerializer(),
Traverser: TraverserSerializer(),