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", fatal=True) 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 = {metajava.dromedary(k): v for k, v in metajava.java_term_info .METHOD_ALIASES.items()} self.visit(node.value) self.write(".") initial = python_clashes.get( node.attr, metajava.dromedary(node.attr)) initial = method_aliases.get(initial, initial) self.write(initial) if initial in metajava.java_term_info.JAVA_KEYWORDS or \ initial in metajava.java_term_info.OBJECT_METHODS: self.write('_') if emit_parens and is_toplevel_constant: self.write('()')
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", fatal=True) 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 = { metajava.dromedary(k): v for k, v in metajava.java_term_info.METHOD_ALIASES.items() } self.visit(node.value) self.write(".") initial = python_clashes.get(node.attr, metajava.dromedary(node.attr)) initial = method_aliases.get(initial, initial) self.write(initial) if initial in metajava.java_term_info.JAVA_KEYWORDS or \ initial in metajava.java_term_info.OBJECT_METHODS: self.write('_') if emit_parens and is_toplevel_constant: self.write('()')
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(metajava.dromedary(node.attr))