# 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
            if isinstance(value, str):
                return value

            if not isinstance(value, dict):
                raise ValidationError(
                    'Value must be dictionary: {!r}'.format(value))
            if not ('input' in value and value['input']):
                raise ValidationError(
                    "'input' key must be present: {!r}".format(value))
            if not isinstance(value['input'], (str, list, tuple)):
                raise ValidationError(
                    "'input' must be either str or list/tuple: {!r}"
                    .format(value))
            if 'output' in value and not isinstance(value['output'], str):
                raise ValidationError(
                    "'output' must be str: {!r}".format(value))
            if 'payload' in value and not isinstance(value['payload'], dict):
                raise ValidationError(
                    "'payload' must be dict or absent: {!r}".format(value))
            if 'weight' in value:
                if isinstance(value['weight'], int):
                    if value['weight'] < 0:
                        raise ValidationError(
                            "'weight' must be greater equal 0: {!r}"
                            .format(value['weight']))
                elif isinstance(value['weight'], str):
                    if not value['weight'].isdigit():
                        raise ValidationError(
                            "'weight' must represent positive integer: {!r}"
                            .format(value['weight']))

# 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

            if isinstance(value, str):
                return value

            if not isinstance(value, dict):
                raise ValidationError(
                    'Value must be dictionary: {!r}'.format(value))
            if not ('input' in value and value['input']):
                raise ValidationError(
                    "'input' key must be present: {!r}".format(value))
            if not isinstance(value['input'], (str, list, tuple)):
                raise ValidationError(
                    "'input' must be either str or list/tuple: {!r}"
                    .format(value))
            if 'output' in value and not isinstance(value['output'], str):
                raise ValidationError(
                    "'output' must be str: {!r}".format(value))
            if 'payload' in value and not isinstance(value['payload'], dict):
                raise ValidationError(
                    "'payload' must be dict or absent: {!r}".format(value))
            if 'weight' in value:
                if isinstance(value['weight'], int):
                    if value['weight'] < 0:
                        raise ValidationError(
                            "'weight' must be greater equal 0: {!r}"
                            .format(value['weight']))
                elif isinstance(value['weight'], str):
                    if not value['weight'].isdigit():
                        raise ValidationError(
                            "'weight' must represent positive integer: {!r}"
                            .format(value['weight']))

                else: