# Path: elasticmagic/util.py
# def clean_params(params, **kwargs):
#     return {
#         p: v for p, v in chain(params.items(), kwargs.items())
#         if v is not None
#     }
# 
# def collect_doc_classes(expr):
#     if hasattr(expr, '_collect_doc_classes'):
#         return expr._collect_doc_classes()
# 
#     if isinstance(expr, dict):
#         return set().union(
#             *[collect_doc_classes(e)
#               for e in chain(expr.keys(), expr.values())]
#         )
# 
#     if isinstance(expr, (list, tuple)):
#         return set().union(*[collect_doc_classes(e) for e in expr])
# 
#     return set()
# 
# Path: elasticmagic/types.py
# def instantiate(typeobj, *args, **kwargs):
#     if inspect.isclass(typeobj):
#         return typeobj(*args, **kwargs)
#     return typeobj
# 
# class Type(object):
#     python_type = None
# 
#     def __init__(self):
#         self.sub_type = None
#         self.doc_cls = None
# 
#     def to_python(self, value):
#         if value is None:
#             return None
#         if self.python_type is not None:
#             return self.python_type(value)
#         return value
# 
#     def to_python_single(self, value):
#         return self.to_python(value)
# 
#     def from_python(self, value, compiler, validate=False):
#         return value
# 
# 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 inspect
import operator
from itertools import count
from .util import clean_params, collect_doc_classes
from .types import instantiate, Type
from .compat import string_types, Mapping
class SpanNot(QueryExpression):
    __query_name__ = 'span_not'

    def __init__(
            self, include, exclude, dist=None, pre=None, post=None, boost=None,
            **kwargs
    ):
        super(SpanNot, self).__init__(
            include=include, exclude=exclude, dist=dist, pre=pre, post=post,
            boost=boost, **kwargs
        )


class SpanOr(QueryExpression):
    __query_name__ = 'span_or'

    def __init__(self, clauses, boost=None, **kwargs):
        super(SpanOr, self).__init__(clauses=clauses, boost=boost, **kwargs)


class SpanTerm(Term):
    __query_name__ = 'span_term'


class Nested(QueryExpression):
    __query_name__ = 'nested'

    def __init__(self, path, query, score_mode=None, **kwargs):
        super(Nested, self).__init__(
            path=path, query=query, score_mode=score_mode, **kwargs

# Path: elasticmagic/util.py
# def clean_params(params, **kwargs):
#     return {
#         p: v for p, v in chain(params.items(), kwargs.items())
#         if v is not None
#     }
# 
# def collect_doc_classes(expr):
#     if hasattr(expr, '_collect_doc_classes'):
#         return expr._collect_doc_classes()
# 
#     if isinstance(expr, dict):
#         return set().union(
#             *[collect_doc_classes(e)
#               for e in chain(expr.keys(), expr.values())]
#         )
# 
#     if isinstance(expr, (list, tuple)):
#         return set().union(*[collect_doc_classes(e) for e in expr])
# 
#     return set()
# 
# Path: elasticmagic/types.py
# def instantiate(typeobj, *args, **kwargs):
#     if inspect.isclass(typeobj):
#         return typeobj(*args, **kwargs)
#     return typeobj
# 
# class Type(object):
#     python_type = None
# 
#     def __init__(self):
#         self.sub_type = None
#         self.doc_cls = None
# 
#     def to_python(self, value):
#         if value is None:
#             return None
#         if self.python_type is not None:
#             return self.python_type(value)
#         return value
# 
#     def to_python_single(self, value):
#         return self.to_python(value)
# 
#     def from_python(self, value, compiler, validate=False):
#         return value
# 
# 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/expression.py
import inspect
import operator
from itertools import count
from .util import clean_params, collect_doc_classes
from .types import instantiate, Type
from .compat import string_types, Mapping

class SpanNot(QueryExpression):
    __query_name__ = 'span_not'

    def __init__(
            self, include, exclude, dist=None, pre=None, post=None, boost=None,
            **kwargs
    ):
        super(SpanNot, self).__init__(
            include=include, exclude=exclude, dist=dist, pre=pre, post=post,
            boost=boost, **kwargs
        )


class SpanOr(QueryExpression):
    __query_name__ = 'span_or'

    def __init__(self, clauses, boost=None, **kwargs):
        super(SpanOr, self).__init__(clauses=clauses, boost=boost, **kwargs)


class SpanTerm(Term):
    __query_name__ = 'span_term'


class Nested(QueryExpression):
    __query_name__ = 'nested'

    def __init__(self, path, query, score_mode=None, **kwargs):
        super(Nested, self).__init__(
            path=path, query=query, score_mode=score_mode, **kwargs

        )