# Path: elasticmagic/compat.py
# PY2 = sys.version_info[0] == 2
# def force_unicode(value):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):


import base64
import datetime
import inspect
import re
import copy
import dateutil.parser
    import geohash
from .compat import binary_type, text_type, string_types

class Double(_Float):
    __visit_name__ = 'double'


class Date(Type):
    __visit_name__ = 'date'

    python_type = datetime.datetime

    # def __init__(self, format=None):
    #     self.format = format

    def to_python(self, value):
        if value is None:
            return None
        return dateutil.parser.parse(value)

    def from_python(self, value, compiler, validate=True):
        if validate:
            if not isinstance(value, datetime.datetime):
                raise ValidationError('Value must be datetime.datetime object')
        return value


class Boolean(Type):
    __visit_name__ = 'boolean'

    python_type = bool


# Path: elasticmagic/compat.py
# PY2 = sys.version_info[0] == 2
# def force_unicode(value):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):


# Path: elasticmagic/types.py
import base64
import datetime
import inspect
import re
import copy
import dateutil.parser
    import geohash
from .compat import binary_type, text_type, string_types


class Double(_Float):
    __visit_name__ = 'double'


class Date(Type):
    __visit_name__ = 'date'

    python_type = datetime.datetime

    # def __init__(self, format=None):
    #     self.format = format

    def to_python(self, value):
        if value is None:
            return None
        return dateutil.parser.parse(value)

    def from_python(self, value, compiler, validate=True):
        if validate:
            if not isinstance(value, datetime.datetime):
                raise ValidationError('Value must be datetime.datetime object')
        return value


class Boolean(Type):
    __visit_name__ = 'boolean'

    python_type = bool


    def to_python(self, value):