# Path: pyknow/conditionalelement.py
# class ConditionalElement(tuple):
#     """Base Conditional Element"""
# 
#     def __new__(cls, *args):
#         return super(ConditionalElement, cls).__new__(cls, args)
# 
#     def __repr__(self):  # pragma: no cover
#         return "%s%s" % (self.__class__.__name__, super().__repr__())
# 
# Path: pyknow/fieldconstraint.py
# class P(Bindable, FieldConstraint):
#     """Predicate Field Constraint"""
#     def __new__(cls, match, __bind__=None):
#         if not isinstance(match, Callable):
#             raise TypeError("PredicateFC needs a callable.")
#         else:
#             obj = super(P, cls).__new__(cls, match)
#             obj.__bind__ = __bind__
#             return obj
# 
#     @property
#     def match(self):
#         return self[0]


from itertools import chain
from .conditionalelement import ConditionalElement
from .fieldconstraint import P
import operator as op
import re
import fnmatch

#: Not equal operator.
NE = _from_operator2(op.ne)

#: Greater than or equal operator.
GE = _from_operator2(op.ge)

#: Greater than operator.
GT = _from_operator2(op.gt)

#: Tests object identity.
IS = _from_operator2(op.is_)

#: Tests object identity.
IS_NOT = _from_operator2(op.is_not)

#: Return the outcome of the test b in a
CONTAINS = _from_operator2(op.contains)


def BETWEEN(a, b):
    """
    The BETWEEN operator selects values within a given range.
    The BETWEEN operator is inclusive: begin and end values are included.

    """
    if any((isinstance(x, ConditionalElement) for x in (a, b))):
        raise TypeError(
            "A ConditionalElement can't be used as an operator condition.")
    else:

# Path: pyknow/conditionalelement.py
# class ConditionalElement(tuple):
#     """Base Conditional Element"""
# 
#     def __new__(cls, *args):
#         return super(ConditionalElement, cls).__new__(cls, args)
# 
#     def __repr__(self):  # pragma: no cover
#         return "%s%s" % (self.__class__.__name__, super().__repr__())
# 
# Path: pyknow/fieldconstraint.py
# class P(Bindable, FieldConstraint):
#     """Predicate Field Constraint"""
#     def __new__(cls, match, __bind__=None):
#         if not isinstance(match, Callable):
#             raise TypeError("PredicateFC needs a callable.")
#         else:
#             obj = super(P, cls).__new__(cls, match)
#             obj.__bind__ = __bind__
#             return obj
# 
#     @property
#     def match(self):
#         return self[0]


# Path: pyknow/operator.py
from itertools import chain
from .conditionalelement import ConditionalElement
from .fieldconstraint import P
import operator as op
import re
import fnmatch


#: Not equal operator.
NE = _from_operator2(op.ne)

#: Greater than or equal operator.
GE = _from_operator2(op.ge)

#: Greater than operator.
GT = _from_operator2(op.gt)

#: Tests object identity.
IS = _from_operator2(op.is_)

#: Tests object identity.
IS_NOT = _from_operator2(op.is_not)

#: Return the outcome of the test b in a
CONTAINS = _from_operator2(op.contains)


def BETWEEN(a, b):
    """
    The BETWEEN operator selects values within a given range.
    The BETWEEN operator is inclusive: begin and end values are included.

    """
    if any((isinstance(x, ConditionalElement) for x in (a, b))):
        raise TypeError(
            "A ConditionalElement can't be used as an operator condition.")
    else:

        return P(lambda x: a <= x <= b)