import textwrap


def _print(attrs, state=None, verbose=0):
    """
    Print attributes which has specific states.
    
    Args:
        attrs (set): Set of attributes.
        state (str): State name which attributes belong to.
        verbose (int): verbosity.
    """

    def formatted(chars, color='', indent=0):
        codes = {
            'purple': '\033[95m',
            'blue': '\033[94m', 'green': '\033[92m',
            'end': '\033[0m'
        }

        start = codes.get(color, '')
        end = codes['end'] if color else ''

        return textwrap.indent(start + chars + end, ' ' * 4 * indent)

    if state is not None:
        print(formatted(f'\n{state.title()} attributes:', 'green'))

    current = {'namespace': '', 'group': ''}
    for attr in attrs:
        if current['group'] != attr.group:
            print(formatted(attr.group, 'blue', 1))
            current['group'] = attr.group

        addition = ''
        if attr.deprecated:
            addition = f' -> [{attr.new.group}]/{attr.new.name}'

        if verbose > 0:
            if current['namespace'] != attr.namespace:
                print(formatted(attr.namespace, 'purple', 2))
                current['namespace'] = attr.namespace
            if attr.deprecated:
                addition = addition + f' ({attr.new.namespace})'

        if verbose > 1:
            addition = addition + f' = {attr.value}'

        print(formatted(attr.name + addition, indent=3 if verbose > 0 else 2))