Skip to content

Commit

Permalink
add RawExpression to gremlin_python
Browse files Browse the repository at this point in the history
As described on dev@tinkerpop.apache.org thread gremlin_python GLV
  • Loading branch information
Leifur Halldor Asgeirsson committed Jun 16, 2016
1 parent 210d1a8 commit e931d21
Show file tree
Hide file tree
Showing 3 changed files with 252 additions and 0 deletions.
Expand Up @@ -179,6 +179,8 @@ builtInRange = range
for arg in args:
if isinstance(arg, dict) and 1 == len(arg) and isinstance(arg.keys()[0],str):
self.bindings.update(arg)
elif isinstance(arg, RawExpression):
self.bindings.update(arg.bindings)
return self
""")
}
Expand Down Expand Up @@ -230,6 +232,31 @@ builtInRange = range
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, dict) and 1 == len(arg) and isinstance(arg.keys()[0],str):
self.bindings.update(arg)
return Raw(arg.popitem()[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(value)
""")

pythonClass.append("\n")

pythonClass.append("""class P(object):
def __init__(self, operator, value, other=None):
self.operator = operator
Expand Down

0 comments on commit e931d21

Please sign in to comment.