# 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/hquery/object_type.py
# def object_type_name(obj):
#     result = 'NULL OR UNKNOWN TYPE'
# 
#     if obj is not None:
#         if isinstance(obj, int):
#             index = obj
#         else:
#             index = object_type(obj)
#         result = TYPE_NAMES[index]
# 
#     return result
# 
# 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)


from itertools import filterfalse
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.hquery.object_type import object_type_name
from hq.soup_util import is_any_node



def make_node_set(node_set, reverse=False):
    ids = set()

    def is_unique_id(node):
        node_id = id(node)
        if node_id in ids:
            return False
        else:
            ids.add(node_id)
            return True

    if not isinstance(node_set, list):
        node_set = [node_set]

    non_node_member = next(filterfalse(is_any_node, node_set), False)
    if non_node_member:
        format_str = 'Constructed node set that includes {0} object "{1}"'

# 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/hquery/object_type.py
# def object_type_name(obj):
#     result = 'NULL OR UNKNOWN TYPE'
# 
#     if obj is not None:
#         if isinstance(obj, int):
#             index = obj
#         else:
#             index = object_type(obj)
#         result = TYPE_NAMES[index]
# 
#     return result
# 
# 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/sequences.py
from itertools import filterfalse
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.hquery.object_type import object_type_name
from hq.soup_util import is_any_node




def make_node_set(node_set, reverse=False):
    ids = set()

    def is_unique_id(node):
        node_id = id(node)
        if node_id in ids:
            return False
        else:
            ids.add(node_id)
            return True

    if not isinstance(node_set, list):
        node_set = [node_set]

    non_node_member = next(filterfalse(is_any_node, node_set), False)
    if non_node_member:
        format_str = 'Constructed node set that includes {0} object "{1}"'

        raise HqueryEvaluationError(format_str.format(object_type_name(non_node_member), non_node_member))