def visit_Attribute(self, node, emit_parens=True):
     is_toplevel_constant = False
     if attr_matches("r.row", node):
         self.skip("Java driver doesn't support r.row")
     elif is_name("r", node.value) and node.attr in self.TOPLEVEL_CONSTANTS:
         # Python has r.minval, r.saturday etc. We need to emit
         # r.minval() and r.saturday()
         is_toplevel_constant = True
     python_clashes = {
         # These are underscored in the python driver to avoid
         # keywords, but they aren't java keywords so we convert
         # them back.
         'or_': 'or',
         'and_': 'and',
         'not_': 'not',
     }
     method_aliases = {dromedary(k): v for k, v in METHOD_ALIASES.items()}
     self.visit(node.value)
     self.write(".")
     initial = python_clashes.get(
         node.attr, dromedary(node.attr))
     initial = method_aliases.get(initial, initial)
     self.write(initial)
     if initial in JAVA_KEYWORDS | OBJECT_METHODS:
         self.write('_')
     if emit_parens and is_toplevel_constant:
         self.write('()')
Example #2
0
 def visit_Attribute(self, node):
     self.visit(node.value)
     self.write(".")
     if node.is_reql:
         self.write(dromedary(node.attr))
     else:
         self.write(node.attr)
Example #3
0
 def visit_keyword(self, node):
     if node.is_reql:
         self.write(dromedary(node.arg))
     else:
         self.write(node.arg)
     self.write(": ")
     self.visit(node.value)
    def visit_Attribute(self, node, emit_parens=True):
        skip_parent = False
        if attr_matches("r.ast", node):
            # The java driver doesn't have that namespace, so we skip
            # the `r.` prefix and create an ast class member in the
            # test file. So stuff like `r.ast.rqlTzinfo(...)` converts
            # to `ast.rqlTzinfo(...)`
            skip_parent = True

        if not skip_parent:
            self.visit(node.value)
            self.write(".")
        self.write(dromedary(node.attr))
Example #5
0
 def visit_Name(self, node):
     if node.is_reql:
         self.write(dromedary(node.id))
     else:
         self.write(dromedary(node.id))