Returns a string with the given formatting.

def get_line(s, bold=False, underline=False, blinking=False, color=None,
             bgcolor=None, update_line=False):
    """
    Returns a string with the given formatting.

    """
    parts = []

    if update_line:
        parts.append(_UPDATE_LINE)

    for val in [color, bgcolor]:
        if val:
            parts.append(val)

    if bold:
        parts.append(_TURN_BOLD_MODE_ON)
    if underline:
        parts.append(_TURN_UNDERLINE_MODE_ON)
    if blinking:
        parts.append(_TURN_BLINKING_MODE_ON)

    parts.append(s)
    parts.append(_TURN_OFF_CHARACTER_ATTS)

    result = ''.join(parts)
    return result