예제 #1
0
 def __init__(self, test_dir, filename, test_output_dir, renderer):
     self.filename = filename
     self.full_path = os.path.join(test_dir, filename)
     self.module_name = metajava.camel(
         filename.split('.')[0].replace('/', '_'))
     self.test_output_dir = test_output_dir
     self.reql_vars = {'r'}
     self.renderer = renderer
예제 #2
0
 def __init__(self, test_dir, filename, test_output_dir, renderer):
     self.filename = filename
     self.full_path = os.path.join(test_dir, filename)
     self.module_name = metajava.camel(
         filename.split('.')[0].replace('/', '_'))
     self.test_output_dir = test_output_dir
     self.reql_vars = {'r'}
     self.renderer = renderer
예제 #3
0
 def __init__(self, test_dir, filename, test_output_dir, renderer):
     self.filename = filename
     self.full_path = os.path.join(test_dir, filename)
     self.module_name = metajava.camel(
         filename.split(".")[0].replace("/", "_"))
     self.test_output_dir = test_output_dir
     self.reql_vars = {"r"}
     self.renderer = renderer
예제 #4
0
def py_to_java_type(py_type):
    '''Converts python types to their Java equivalents'''
    if py_type is None:
        return None
    elif isinstance(py_type, str):
        # This can be called on something already converted
        return py_type
    elif py_type.__name__ == 'function':
        return 'ReqlFunction1'
    elif (py_type.__module__ == 'datetime' and
          py_type.__name__ == 'datetime'):
        return 'OffsetDateTime'
    elif py_type.__module__ == 'builtins':
        return {
            bool: 'Boolean',
            bytes: 'byte[]',
            int: 'Long',
            float: 'Double',
            str: 'String',
            dict: 'Map',
            list: 'List',
            object: 'Object',
            type(None): 'Object',
        }[py_type]
    elif py_type.__module__ == 'rethinkdb.ast':
        # Anomalous non-rule based capitalization in the python driver
        return {
            'DB': 'Db'
        }.get(py_type.__name__, py_type.__name__)
    elif py_type.__module__ == 'rethinkdb.errors':
        return py_type.__name__
    elif py_type.__module__ == '?test?':
        return {
            'uuid': 'UUIDMatch',  # clashes with ast.Uuid
        }.get(py_type.__name__, metajava.camel(py_type.__name__))
    elif py_type.__module__ == 'rethinkdb.query':
        # All of the constants like minval maxval etc are defined in
        # query.py, but no type name is provided to `type`, so we have
        # to pull it out of a class variable
        return metajava.camel(py_type.st)
    else:
        raise Unhandled(
            "Don't know how to convert python type {}.{} to java"
            .format(py_type.__module__, py_type.__name__))
예제 #5
0
def py_to_java_type(py_type, node):
    """Converts python types to their Java equivalents"""
    if py_type is None:
        return None
    elif isinstance(py_type, str):
        # This can be called on something already converted
        return py_type
    elif py_type.__name__ == "function":
        return "ReqlFunction1"
    elif py_type.__module__ == "datetime" and py_type.__name__ == "datetime":
        return "OffsetDateTime"
    elif py_type.__module__ == "builtins":
        return {
            bool: "Boolean",
            bytes: "byte[]",
            int: "Long",
            float: "Double",
            str: "String",
            dict: "Map",
            list: "List",
            object: "Object",
            type(None): "Object",
        }[py_type]
    elif py_type.__module__ == "rethinkdb.ast":
        # Anomalous non-rule based capitalization in the python driver
        return {"DB": "Db"}.get(py_type.__name__, py_type.__name__)
    elif py_type.__module__ == "rethinkdb.errors":
        return py_type.__name__
    elif py_type.__module__ == "?test?":
        return {
            "uuid": "UUIDMatch"
        }.get(  # clashes with ast.Uuid
            py_type.__name__, metajava.camel(py_type.__name__))
    elif py_type.__module__ == "rethinkdb.query":
        # All of the constants like minval maxval etc are defined in
        # query.py, but no type name is provided to `type`, so we have
        # to pull it out of a class variable
        assert py_type.__name__ == "RqlConstant"
        return metajava.camel(node.st)
    else:
        raise Unhandled(
            "Don't know how to convert python type {}.{} to java".format(
                py_type.__module__, py_type.__name__))
예제 #6
0
def py_to_java_type(py_type):
    '''Converts python types to their Java equivalents'''
    if py_type is None:
        return None
    elif isinstance(py_type, str):
        # This can be called on something already converted
        return py_type
    elif py_type.__name__ == 'function':
        return 'ReqlFunction1'
    elif (py_type.__module__ == 'datetime' and py_type.__name__ == 'datetime'):
        return 'OffsetDateTime'
    elif py_type.__module__ == 'builtins':
        return {
            bool: 'Boolean',
            bytes: 'byte[]',
            int: 'Long',
            float: 'Double',
            str: 'String',
            dict: 'Map',
            list: 'List',
            object: 'Object',
            type(None): 'Object',
        }[py_type]
    elif py_type.__module__ == 'rethinkdb.ast':
        # Anomalous non-rule based capitalization in the python driver
        return {'DB': 'Db'}.get(py_type.__name__, py_type.__name__)
    elif py_type.__module__ == 'rethinkdb.errors':
        return py_type.__name__
    elif py_type.__module__ == '?test?':
        return {
            'uuid': 'UUIDMatch',  # clashes with ast.Uuid
        }.get(py_type.__name__, metajava.camel(py_type.__name__))
    elif py_type.__module__ == 'rethinkdb.query':
        # All of the constants like minval maxval etc are defined in
        # query.py, but no type name is provided to `type`, so we have
        # to pull it out of a class variable
        return metajava.camel(py_type.st)
    else:
        raise Unhandled(
            "Don't know how to convert python type {}.{} to java".format(
                py_type.__module__, py_type.__name__))