# Path: hq/hquery/functions/core_string.py
# def string(*args):
#     if len(args) == 1:
#         return string_value(args[0])
#     else:
#         return string_value(get_context_node())
# 
# Path: hq/verbosity.py
# def verbose_print(text, indent_after=False, outdent_before=False):
#     if settings.VERBOSE:
#         if outdent_before:
#             pop_indent()
#         if not is_a_string(text):
#             text = text()
#         print(u'{0}{1}'.format(' ' * indent_level, text), file=sys.stderr)
#         if indent_after:
#             push_indent()
# 
# Path: hq/hquery/functions/core_boolean.py
# class boolean:
# 
#     def __init__(self, obj):
#         if is_node_set(obj):
#             self.value = len(obj) > 0
#         elif is_number(obj):
#             f = float(obj)
#             self.value = bool(f) and not isnan(f)
#         else:
#             self.value = bool(obj)
# 
#     def __bool__(self):
#         return self.value
# 
#     def __nonzero__(self):
#         return self.__bool__()
# 
#     def __str__(self):
#         return str(self.value).lower()
# 
#     def __eq__(self, other):
#         return is_boolean(other) and self.value == other.value
# 
#     def __repr__(self):
#         return 'boolean({0})'.format(self.value)
# 
# Path: hq/hquery/functions/core_number.py
# class number:
# 
#     def __init__(self, obj):
#         if isinstance(obj, number):
#             self.value = obj.value
#         elif is_boolean(obj):
#             self.value = 1 if obj else 0
#         elif is_node_set(obj) or is_any_node(obj):
#             self.value = self._int_or_float(float(string_value(obj)))
#         else:
#             try:
#                 self.value = self._int_or_float(float(obj))
#             except ValueError:
#                 self.value = float('nan')
# 
#     def __float__(self):
#         return float(self.value)
# 
#     def __int__(self):
#         return int(self.value)
# 
#     def __str__(self):
#         result = str(self.value)
#         if result == 'nan':
#             result = 'NaN'
#         return result
# 
#     def __hash__(self):
#         return self.value.__hash__()
# 
#     def __add__(self, other):
#         return number(self.value + self._value_of_other_operand(other))
# 
#     def __sub__(self, other):
#         return number(self.value - self._value_of_other_operand(other))
# 
#     def __neg__(self):
#         return number(-self.value)
# 
#     def __mul__(self, other):
#         return number(self.value * self._value_of_other_operand(other))
# 
#     def __div__(self, other):
#         return self.__truediv__(other)
# 
#     def __truediv__(self, other):
#         other = self._value_of_other_operand(other)
#         if other == 0:
#             return number(float('nan'))
#         else:
#             return number(self.value / other)
# 
#     def __mod__(self, other):
#         return number(self.value % self._value_of_other_operand(other))
# 
#     def __eq__(self, other):
#         return self.value == self._value_of_other_operand(other)
# 
#     def __ge__(self, other):
#         return self.value >= self._value_of_other_operand(other)
# 
#     def __gt__(self, other):
#         return self.value > self._value_of_other_operand(other)
# 
#     def __le__(self, other):
#         return self.value <= self._value_of_other_operand(other)
# 
#     def __lt__(self, other):
#         return self.value < self._value_of_other_operand(other)
# 
#     def __repr__(self):
#         return 'number({0})'.format(str(self.value))
# 
#     @staticmethod
#     def _int_or_float(numeric_value):
#         if isinstance(numeric_value, int) or numeric_value % 1 != 0:
#             return numeric_value
#         else:
#             return int(numeric_value)
# 
#     @staticmethod
#     def _value_of_other_operand(other):
#         return other.value if is_number(other) else other
# 
# Path: hq/hquery/object_type.py
# def object_type(obj):
#     if is_boolean(obj):
#         return BOOLEAN
#     elif is_node_set(obj):
#         return SEQUENCE
#     elif is_sequence(obj):
#         return SEQUENCE
#     elif is_number(obj):
#         return NUMBER
#     elif is_string(obj):
#         return STRING
#     else:
#         verbose_print('UH-OH! Returning None from object_type({0})'.format(obj.__class__.__name__))
#         return None
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# Path: hq/hquery/syntax_error.py
# class HquerySyntaxError(ValueError):
#     pass


from operator import gt, lt, ge, le
from hq.hquery.functions.core_string import string
from hq.verbosity import verbose_print
from hq.hquery.functions.core_boolean import boolean
from hq.hquery.functions.core_number import number
from hq.hquery.object_type import object_type, is_boolean, is_number
from hq.hquery.syntax_error import HquerySyntaxError



class RelationalOperator:

    def __init__(self, op):
        if op == '>':
            self.base_op = gt
        elif op == '>=':
            self.base_op = ge
        elif op == '<':
            self.base_op = lt
        elif op == '<=':
            self.base_op = le
        else:
            raise HquerySyntaxError('unexpected relational operator "{0}"'.format(op))


    def evaluate(self, first, second):

# Path: hq/hquery/functions/core_string.py
# def string(*args):
#     if len(args) == 1:
#         return string_value(args[0])
#     else:
#         return string_value(get_context_node())
# 
# Path: hq/verbosity.py
# def verbose_print(text, indent_after=False, outdent_before=False):
#     if settings.VERBOSE:
#         if outdent_before:
#             pop_indent()
#         if not is_a_string(text):
#             text = text()
#         print(u'{0}{1}'.format(' ' * indent_level, text), file=sys.stderr)
#         if indent_after:
#             push_indent()
# 
# Path: hq/hquery/functions/core_boolean.py
# class boolean:
# 
#     def __init__(self, obj):
#         if is_node_set(obj):
#             self.value = len(obj) > 0
#         elif is_number(obj):
#             f = float(obj)
#             self.value = bool(f) and not isnan(f)
#         else:
#             self.value = bool(obj)
# 
#     def __bool__(self):
#         return self.value
# 
#     def __nonzero__(self):
#         return self.__bool__()
# 
#     def __str__(self):
#         return str(self.value).lower()
# 
#     def __eq__(self, other):
#         return is_boolean(other) and self.value == other.value
# 
#     def __repr__(self):
#         return 'boolean({0})'.format(self.value)
# 
# Path: hq/hquery/functions/core_number.py
# class number:
# 
#     def __init__(self, obj):
#         if isinstance(obj, number):
#             self.value = obj.value
#         elif is_boolean(obj):
#             self.value = 1 if obj else 0
#         elif is_node_set(obj) or is_any_node(obj):
#             self.value = self._int_or_float(float(string_value(obj)))
#         else:
#             try:
#                 self.value = self._int_or_float(float(obj))
#             except ValueError:
#                 self.value = float('nan')
# 
#     def __float__(self):
#         return float(self.value)
# 
#     def __int__(self):
#         return int(self.value)
# 
#     def __str__(self):
#         result = str(self.value)
#         if result == 'nan':
#             result = 'NaN'
#         return result
# 
#     def __hash__(self):
#         return self.value.__hash__()
# 
#     def __add__(self, other):
#         return number(self.value + self._value_of_other_operand(other))
# 
#     def __sub__(self, other):
#         return number(self.value - self._value_of_other_operand(other))
# 
#     def __neg__(self):
#         return number(-self.value)
# 
#     def __mul__(self, other):
#         return number(self.value * self._value_of_other_operand(other))
# 
#     def __div__(self, other):
#         return self.__truediv__(other)
# 
#     def __truediv__(self, other):
#         other = self._value_of_other_operand(other)
#         if other == 0:
#             return number(float('nan'))
#         else:
#             return number(self.value / other)
# 
#     def __mod__(self, other):
#         return number(self.value % self._value_of_other_operand(other))
# 
#     def __eq__(self, other):
#         return self.value == self._value_of_other_operand(other)
# 
#     def __ge__(self, other):
#         return self.value >= self._value_of_other_operand(other)
# 
#     def __gt__(self, other):
#         return self.value > self._value_of_other_operand(other)
# 
#     def __le__(self, other):
#         return self.value <= self._value_of_other_operand(other)
# 
#     def __lt__(self, other):
#         return self.value < self._value_of_other_operand(other)
# 
#     def __repr__(self):
#         return 'number({0})'.format(str(self.value))
# 
#     @staticmethod
#     def _int_or_float(numeric_value):
#         if isinstance(numeric_value, int) or numeric_value % 1 != 0:
#             return numeric_value
#         else:
#             return int(numeric_value)
# 
#     @staticmethod
#     def _value_of_other_operand(other):
#         return other.value if is_number(other) else other
# 
# Path: hq/hquery/object_type.py
# def object_type(obj):
#     if is_boolean(obj):
#         return BOOLEAN
#     elif is_node_set(obj):
#         return SEQUENCE
#     elif is_sequence(obj):
#         return SEQUENCE
#     elif is_number(obj):
#         return NUMBER
#     elif is_string(obj):
#         return STRING
#     else:
#         verbose_print('UH-OH! Returning None from object_type({0})'.format(obj.__class__.__name__))
#         return None
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# Path: hq/hquery/syntax_error.py
# class HquerySyntaxError(ValueError):
#     pass


# Path: hq/hquery/relational_operators.py
from operator import gt, lt, ge, le
from hq.hquery.functions.core_string import string
from hq.verbosity import verbose_print
from hq.hquery.functions.core_boolean import boolean
from hq.hquery.functions.core_number import number
from hq.hquery.object_type import object_type, is_boolean, is_number
from hq.hquery.syntax_error import HquerySyntaxError




class RelationalOperator:

    def __init__(self, op):
        if op == '>':
            self.base_op = gt
        elif op == '>=':
            self.base_op = ge
        elif op == '<':
            self.base_op = lt
        elif op == '<=':
            self.base_op = le
        else:
            raise HquerySyntaxError('unexpected relational operator "{0}"'.format(op))


    def evaluate(self, first, second):

        first_type = object_type(first)