# 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
>>> HEIGHT = 480
>>>
>>> class Player(Fact):
...      pass
...
>>>
>>> @Rule(
...      Player(
...          x=MATCH.x & GE(0) & LE(WIDTH),
...          y=MATCH.y & BETWEEN(0, HEIGHT),
...          name=MATCH.name & (CALL.startswith("@") | CALL.endswith("_ADM"))
...      )
... )
... def admin_in_visible_area(self, x, y, name):
...     pass
...

"""


__all__ = ['TRUTH', 'LT', 'LE', 'EQ', 'NE', 'GE', 'GT', 'IS', 'IS_NOT',
           'CONTAINS', 'BETWEEN', 'CALL', 'REGEX', 'LIKE', 'ILIKE']


def _from_operator2(o):
    def __from_operator2(b):
        if isinstance(b, ConditionalElement):
            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

>>> HEIGHT = 480
>>>
>>> class Player(Fact):
...      pass
...
>>>
>>> @Rule(
...      Player(
...          x=MATCH.x & GE(0) & LE(WIDTH),
...          y=MATCH.y & BETWEEN(0, HEIGHT),
...          name=MATCH.name & (CALL.startswith("@") | CALL.endswith("_ADM"))
...      )
... )
... def admin_in_visible_area(self, x, y, name):
...     pass
...

"""


__all__ = ['TRUTH', 'LT', 'LE', 'EQ', 'NE', 'GE', 'GT', 'IS', 'IS_NOT',
           'CONTAINS', 'BETWEEN', 'CALL', 'REGEX', 'LIKE', 'ILIKE']


def _from_operator2(o):
    def __from_operator2(b):
        if isinstance(b, ConditionalElement):
            raise TypeError(
                "A ConditionalElement can't be used as an operator condition.")
        else:

            return P(lambda a: o(a, b))