# Path: hq/string_util.py
# def truncate_string(s, length, one_line=True, suffix='...'):
#     if len(s) <= length:
#         result = s
#     else:
#         result = s[:length + 1].rsplit(' ', 1)[0] + suffix
#     if one_line:
#         result = result.replace('\n', '\\n')
#     return 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()


import re
from builtins import str
from bs4 import BeautifulSoup
from .string_util import truncate_string
from .verbosity import verbose_print



class AttributeNode:

    def __init__(self, name, value):
        self.name = name
        self.value = ' '.join(value) if isinstance(value, list) else value

    def __repr__(self):
        return 'AttributeNode("{0}", "{1}")'.format(self.name, self.value)

    @classmethod
    def enumerate(cls, node):
        if hasattr(node, 'hq_attrs') and _isnt_root_with_odd_ghost_hq_attrs_on_it_for_reasons_i_dont_understand(node):
            return node.hq_attrs
        else:
            return []


def debug_dump_long_string(s, length=50, one_line=True, suffix='...'):

# Path: hq/string_util.py
# def truncate_string(s, length, one_line=True, suffix='...'):
#     if len(s) <= length:
#         result = s
#     else:
#         result = s[:length + 1].rsplit(' ', 1)[0] + suffix
#     if one_line:
#         result = result.replace('\n', '\\n')
#     return 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/soup_util.py
import re
from builtins import str
from bs4 import BeautifulSoup
from .string_util import truncate_string
from .verbosity import verbose_print




class AttributeNode:

    def __init__(self, name, value):
        self.name = name
        self.value = ' '.join(value) if isinstance(value, list) else value

    def __repr__(self):
        return 'AttributeNode("{0}", "{1}")'.format(self.name, self.value)

    @classmethod
    def enumerate(cls, node):
        if hasattr(node, 'hq_attrs') and _isnt_root_with_odd_ghost_hq_attrs_on_it_for_reasons_i_dont_understand(node):
            return node.hq_attrs
        else:
            return []


def debug_dump_long_string(s, length=50, one_line=True, suffix='...'):

    return truncate_string(s, length, one_line, suffix)