# 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/soup_util.py
# def debug_dump_node(obj):
#     if is_root_node(obj):
#         return 'ROOT DOCUMENT'
#     elif is_tag_node(obj):
#         return u'ELEMENT {0}'.format(debug_dump_long_string(str(obj)))
#     elif is_attribute_node(obj):
#         return 'ATTRIBUTE {0}="{1}"'.format(obj.name, debug_dump_long_string(obj.value))
#     elif is_text_node(obj):
#         return u'TEXT "{0}"'.format(debug_dump_long_string(obj.string))
#     elif is_comment_node(obj):
#         return u'COMMENT "{0}"'.format(debug_dump_long_string(obj.string))
#     else:
#         return 'NODE type {0}'.format(obj.__class__.__name__)


from hq.verbosity import verbose_print
from ..soup_util import debug_dump_node
            self.preserve_space = preserve_space
        else:
            try:
                self.preserve_space = peek_context().preserve_space
            except ExpressionStackEmptyError:
                self.preserve_space = False

    def __str__(self):
        return 'context(node={0})'.format(str(self.node))


class ExpressionStackEmptyError(RuntimeError):
    pass



def get_context_node():
    return peek_context().node


def peek_context():
    try:
        return context_stack[-1]
    except IndexError:
        raise ExpressionStackEmptyError('tried to peek while expression stack was empty')


def pop_context():
    result = context_stack.pop()
    msg = u'Popping (node={0}, position={1}, size={2} off of context stack.'

# 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/soup_util.py
# def debug_dump_node(obj):
#     if is_root_node(obj):
#         return 'ROOT DOCUMENT'
#     elif is_tag_node(obj):
#         return u'ELEMENT {0}'.format(debug_dump_long_string(str(obj)))
#     elif is_attribute_node(obj):
#         return 'ATTRIBUTE {0}="{1}"'.format(obj.name, debug_dump_long_string(obj.value))
#     elif is_text_node(obj):
#         return u'TEXT "{0}"'.format(debug_dump_long_string(obj.string))
#     elif is_comment_node(obj):
#         return u'COMMENT "{0}"'.format(debug_dump_long_string(obj.string))
#     else:
#         return 'NODE type {0}'.format(obj.__class__.__name__)


# Path: hq/hquery/expression_context.py
from hq.verbosity import verbose_print
from ..soup_util import debug_dump_node

            self.preserve_space = preserve_space
        else:
            try:
                self.preserve_space = peek_context().preserve_space
            except ExpressionStackEmptyError:
                self.preserve_space = False

    def __str__(self):
        return 'context(node={0})'.format(str(self.node))


class ExpressionStackEmptyError(RuntimeError):
    pass



def get_context_node():
    return peek_context().node


def peek_context():
    try:
        return context_stack[-1]
    except IndexError:
        raise ExpressionStackEmptyError('tried to peek while expression stack was empty')


def pop_context():
    result = context_stack.pop()
    msg = u'Popping (node={0}, position={1}, size={2} off of context stack.'

    verbose_print(lambda: msg.format(debug_dump_node(result.node), result.position, result.size))