# 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
    def to_python_single(self, value):
        v = self.to_python(value)
        if v:
            return v[0]

    def from_python(self, value, compiler, validate=False):
        if not isinstance(value, self.python_type):
            value = [value]
        return [
            self.sub_type.from_python(v, compiler, validate=validate)
            for v in value
        ]


class GeoPoint(Type):
    __visit_name__ = 'geo_point'

    LAT_LON_SEPARATOR = ','

    python_type = dict

    def to_python(self, value):
        if value is None:
            return None
        if isinstance(value, (list, tuple)):
            value = list(reversed(value))
        if isinstance(value, string_types):
            if self.LAT_LON_SEPARATOR in value:
                value = list(value.split(self.LAT_LON_SEPARATOR))
            elif GEOHASH_IMPORTED:

# 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

    def to_python_single(self, value):
        v = self.to_python(value)
        if v:
            return v[0]

    def from_python(self, value, compiler, validate=False):
        if not isinstance(value, self.python_type):
            value = [value]
        return [
            self.sub_type.from_python(v, compiler, validate=validate)
            for v in value
        ]


class GeoPoint(Type):
    __visit_name__ = 'geo_point'

    LAT_LON_SEPARATOR = ','

    python_type = dict

    def to_python(self, value):
        if value is None:
            return None
        if isinstance(value, (list, tuple)):
            value = list(reversed(value))
        if isinstance(value, string_types):
            if self.LAT_LON_SEPARATOR in value:
                value = list(value.split(self.LAT_LON_SEPARATOR))
            elif GEOHASH_IMPORTED:

                value = list(geohash.decode(value))