# Path: hq/hquery/object_type.py
# def debug_dump_anything(obj):
#     if is_any_node(obj):
#         result = debug_dump_node(obj)
#     elif is_boolean(obj) or is_number(obj) or is_hash(obj) or is_array(obj):
#         result = repr(obj)
#     elif is_string(obj):
#         result = u'string("{0}")'.format(obj)
#     elif is_node_set(obj):
#         result = u'node-set({0})'.format(', '.join(truncate_string(debug_dump_node(node), 20) for node in obj))
#     elif is_sequence(obj):
#         result = u'sequence({0})'.format(', '.join(truncate_string(debug_dump_anything(item), 20) for item in obj))
#     else:
#         raise RuntimeError("debug_dump_anything doesn't know how to handle {0}".format(obj.__class__.__name__))
#     return debug_dump_long_string(result)
# 
# 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()


from hq.hquery.object_type import debug_dump_anything
from hq.verbosity import verbose_print


class ComputedHashKeyValueConstructor:

    def __init__(self, key):
        self.key = key
        self.value_fn = None


    def set_value(self, fn):
        self.value_fn = fn


    def evaluate(self):
        verbose_print('Evaluating value expression for constructed hash key "{0}"'.format(self.key), indent_after=True)

        value = self.value_fn()

        msg = u'Finished evaluating; value of constructed hash key "{0}" is {1}'

# Path: hq/hquery/object_type.py
# def debug_dump_anything(obj):
#     if is_any_node(obj):
#         result = debug_dump_node(obj)
#     elif is_boolean(obj) or is_number(obj) or is_hash(obj) or is_array(obj):
#         result = repr(obj)
#     elif is_string(obj):
#         result = u'string("{0}")'.format(obj)
#     elif is_node_set(obj):
#         result = u'node-set({0})'.format(', '.join(truncate_string(debug_dump_node(node), 20) for node in obj))
#     elif is_sequence(obj):
#         result = u'sequence({0})'.format(', '.join(truncate_string(debug_dump_anything(item), 20) for item in obj))
#     else:
#         raise RuntimeError("debug_dump_anything doesn't know how to handle {0}".format(obj.__class__.__name__))
#     return debug_dump_long_string(result)
# 
# 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/computed_constructors/hash_key_value.py
from hq.hquery.object_type import debug_dump_anything
from hq.verbosity import verbose_print



class ComputedHashKeyValueConstructor:

    def __init__(self, key):
        self.key = key
        self.value_fn = None


    def set_value(self, fn):
        self.value_fn = fn


    def evaluate(self):
        verbose_print('Evaluating value expression for constructed hash key "{0}"'.format(self.key), indent_after=True)

        value = self.value_fn()

        msg = u'Finished evaluating; value of constructed hash key "{0}" is {1}'

        verbose_print(lambda: msg.format(self.key, debug_dump_anything(value)), outdent_before=True)