def color_str(color, raw_str):
    """Format a string with color.

    :param color: a color name, can be r, g, b or y
    :param raw_str: the string to be formatted
    :returns: a colorful string
    """
    if color == 'r':
        fore = 31
    elif color == 'g':
        fore = 32
    elif color == 'b':
        fore = 36
    elif color == 'y':
        fore = 33
    else:
        fore = 37
    color = "\x1B[%d;%dm" % (1, fore)
    return "%s%s\x1B[0m" % (color, raw_str)