# 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

variable_stack = []
NAME, VALUE = range(2)


class variable_scope:
    def __enter__(self):
        self.mark = len(variable_stack)

    def __exit__(self, *args):
        del variable_stack[self.mark:]


def push_variable(name, value):
    global variable_stack

# 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/variables.py
from hq.hquery.object_type import debug_dump_anything
from hq.verbosity import verbose_print


variable_stack = []
NAME, VALUE = range(2)


class variable_scope:
    def __enter__(self):
        self.mark = len(variable_stack)

    def __exit__(self, *args):
        del variable_stack[self.mark:]


def push_variable(name, value):
    global variable_stack

    verbose_print(lambda: u'Pushing variable onto stack: let ${0} := {1}'.format(name, debug_dump_anything(value)))