(attr, text)
return ''.join(result)
Format ``text`` with a color and/or some attributes::

        color       normal color
        *color*     bold color
        _color_     underlined color
        +color+     blinking color
Format ``text`` with a color and/or some attributes::
Format text with a color and / or some attributes ::
def ansiformat(attr, text):
    """
    Format ``text`` with a color and/or some attributes::

        color       normal color
        *color*     bold color
        _color_     underlined color
        +color+     blinking color
    """
    result = []
    if attr[:1] == attr[-1:] == '+':
        result.append(codes['blink'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '*':
        result.append(codes['bold'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '_':
        result.append(codes['underline'])
        attr = attr[1:-1]
    result.append(codes[attr])
    result.append(text)
    result.append(codes['reset'])
    return ''.join(result)
def ansiformat ( attr , text ) : result = [ ] if attr [ : 1 ] == attr [ - 1 : ] == '+' : result . append ( codes [ 'blink' ] ) attr = attr [ 1 : - 1 ] if attr [ : 1 ] == attr [ - 1 : ] == '*' : result . append ( codes [ 'bold' ] ) attr = attr [ 1 : - 1 ] if attr [ : 1 ] == attr [ - 1 : ] == '_' : result . append ( codes [ 'underline' ] ) attr = attr [ 1 : - 1 ] result . append ( codes [ attr ] ) result . append ( text ) result . append ( codes [ 'reset' ] ) return '' . join ( result )