# Path: hq/hquery/evaluation_error.py
# class HqueryEvaluationError(RuntimeError):
# 
#     @classmethod
#     def must_be_node_set(cls, obj):
#         if not is_node_set(obj):
#             raise HqueryEvaluationError('Expected a node set, but found a(n) {0}'.format(obj.__class__.__name__))
# 
#     @classmethod
#     def must_be_node_set_or_sequence(cls, obj):
#         if not (is_node_set(obj) or is_sequence(obj)):
#             raise HqueryEvaluationError('Expected a node set or sequence, but found a(n) {0}'.format(
#                 obj.__class__.__name__
#             ))
# 
# Path: hq/soup_util.py
# def is_any_node(obj):
#     return is_root_node(obj) or is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj) or is_comment_node(obj)
# 
# Path: hq/hquery/object_type.py
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# def is_node_set(obj):
#     return isinstance(obj, list) and all(is_any_node(x) for x in obj)
# 
# def string_value(obj):
#     if is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj):
#         return derive_text_from_node(obj, peek_context().preserve_space)
#     elif is_number(obj) or is_boolean(obj):
#         return str(obj)
#     elif is_node_set(obj):
#         return string_value(obj[0]) if len(obj) > 0 else ''
#     elif is_sequence(obj):
#         return ''.join(string_value(item) for item in obj)
#     elif is_string(obj):
#         return obj
#     else:
#         raise NotImplementedError('string_value not implemented for type "{0}"'.format(obj.__class__.__name__))
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# Path: hq/hquery/sequences.py
# def make_sequence(sequence):
#     if not isinstance(sequence, list):
#         sequence = [sequence]
#     return sequence


import math
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.soup_util import is_any_node
from hq.hquery.object_type import is_number, is_node_set, string_value, is_boolean
from hq.hquery.sequences import make_sequence


exports = ('ceiling', 'floor', 'number', 'round_', 'sum')


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

# Path: hq/hquery/evaluation_error.py
# class HqueryEvaluationError(RuntimeError):
# 
#     @classmethod
#     def must_be_node_set(cls, obj):
#         if not is_node_set(obj):
#             raise HqueryEvaluationError('Expected a node set, but found a(n) {0}'.format(obj.__class__.__name__))
# 
#     @classmethod
#     def must_be_node_set_or_sequence(cls, obj):
#         if not (is_node_set(obj) or is_sequence(obj)):
#             raise HqueryEvaluationError('Expected a node set or sequence, but found a(n) {0}'.format(
#                 obj.__class__.__name__
#             ))
# 
# Path: hq/soup_util.py
# def is_any_node(obj):
#     return is_root_node(obj) or is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj) or is_comment_node(obj)
# 
# Path: hq/hquery/object_type.py
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# def is_node_set(obj):
#     return isinstance(obj, list) and all(is_any_node(x) for x in obj)
# 
# def string_value(obj):
#     if is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj):
#         return derive_text_from_node(obj, peek_context().preserve_space)
#     elif is_number(obj) or is_boolean(obj):
#         return str(obj)
#     elif is_node_set(obj):
#         return string_value(obj[0]) if len(obj) > 0 else ''
#     elif is_sequence(obj):
#         return ''.join(string_value(item) for item in obj)
#     elif is_string(obj):
#         return obj
#     else:
#         raise NotImplementedError('string_value not implemented for type "{0}"'.format(obj.__class__.__name__))
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# Path: hq/hquery/sequences.py
# def make_sequence(sequence):
#     if not isinstance(sequence, list):
#         sequence = [sequence]
#     return sequence


# Path: hq/hquery/functions/core_number.py
import math
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.soup_util import is_any_node
from hq.hquery.object_type import is_number, is_node_set, string_value, is_boolean
from hq.hquery.sequences import make_sequence



exports = ('ceiling', 'floor', 'number', 'round_', 'sum')


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):