Implements string formatting along with color specified in colorama.Fore
332761
def colorize(string, color, *args, **kwargs):
    
    string = string.format(*args, **kwargs)
    return color + string + colorama.Fore.RESET
214647
public static Color toColor(final String colorString) {
        String trimmedString = colorString.trim();
        Color color = null;
        if (trimmedString.startsWith("#")) {
            final int shortHexCode = 4;
            if (trimmedString.length() == shortHexCode) {
                StringBuilder builder = new StringBuilder("#");
                for (int i = 1; i < trimmedString.length(); i++) {
                    builder.append(trimmedString.charAt(i));
                    builder.append(trimmedString.charAt(i));
                }
                color = SLD.toColor(builder.toString());
            } else {
                color = SLD.toColor(trimmedString);
            }
        }

        if (color == null) {
            color = parseRgbColor(trimmedString);
        }

        if (color == null) {
            color = parseRgbaColor(trimmedString);
        }

        if (color == null) {
            color = parseHslColor(trimmedString);
        }

        if (color == null) {
            color = parseHslaColor(trimmedString);
        }

        if (color == null) {
            final Field[] fields = Color.class.getFields();
            for (Field field: fields) {
                if (field.getType() == Color.class && Modifier.isFinal(field.getModifiers())
                        && Modifier.isStatic(field.getModifiers()) &&
                        field.getName().equalsIgnoreCase(trimmedString)) {
                    try {
                        return (Color) field.get(null);
                    } catch (IllegalAccessException e) {
                        throw new Error(e);
                    }
                }
            }
            color = Color.decode(trimmedString);
        }

        return color;
    }
1292482
def format_fore(
        number: FormatArg,
        light: Optional[bool] = False,
        extended: Optional[bool] = False) -> str:
    
    return _format_code(
        number,
        backcolor=False,
        light=light,
        extended=extended
    )
341753
def colorize(text, color=None, **kwargs):
    
    style = None
    bg = None
    # ================ #
    # Keyword checking #
    # ================ #
    if 'style' in kwargs:
        if kwargs['style'] not in STYLE:
            raise WrongStyle('"{}" is wrong argument for {}'.format(kwargs['style'], 'style'))
        style = kwargs['style']

    if 'bg' in kwargs:
        if kwargs['bg'] not in BACKGROUND:
            raise WrongBackground('"{}" is wrong argument for {}'.format(kwargs['bg'], 'bg'))
        bg = kwargs['bg']

    if color not in COLOR:
        raise WrongColor('"{}" is wrong argument for {}'.format(color, 'color'))
    # ===================== #
    # Colorizing the string #
    # ===================== #
    if '\x1b[0m' not in text:
        text = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
               + 'm' + text + '\x1b[0m'
    else:
        lst = text.split('\x1b[0m')
        text = ''
        for x in lst:
            if not x.startswith('\x1b['):
                x = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
                     + 'm' + x + '\x1b[0m'
            else:
                x += '\x1b[0m'
            text += x
    return text
516470
def append(self, p_string, p_color):
        
        self.colors[len(self.data)] = p_color
        self.data += p_string
233769
def :
    
    # All argument types must be str.
    rtext = [str(f) for f in text]

    return COLORIZE_FORMAT.format(
        _to_int(bg), _to_int(base), _to_int(fg), ''.join(rtext)
    )
920050
def formatcolor(string, fg=None, bg=None):
    
    if fg is bg is None:
        return string

    temp = (['fg='+fg] if fg else []) +\
           (['bg='+bg] if bg else [])
    fmt = _color_format_parser._COLOR_DELIM.join(temp)

    return _color_format_parser._START_TOKEN + fmt +\
        _color_format_parser._FMT_TOKEN + string +\
        _color_format_parser._STOP_TOKEN
1054763
def yellow(cls, string, auto=False):
        
        return cls.colorize('yellow', string, auto=auto)
1188349
public static Color fromString(String value) {
    for (Converter converter : CONVERTERS) {
      Color color = converter.getColor(value);
      if (color != null) {
        return color;
      }
    }
    throw new IllegalArgumentException(
        String.format("Did not know how to convert %s into color", value)
    );
  }
1154884
public void format(StringBuffer fmt, Set done, Set todo, int indent) {
    formatName(fmt, indent);
    fmt.append("*(\n");
    itemType.format(fmt, done, todo, indent + 2);
    fmt.append("\n");
    indent(fmt, indent);
    fmt.append(")*");
  }
805430
function nameToHex(color: string): string {
  if (typeof color !== 'string') return color
  const normalizedColorName = color.toLowerCase()
  return namedColorMap[normalizedColorName]
    ? `#${namedColorMap[normalizedColorName]}`
    : color
}
1237581
@Override
    public Color getColor( final String     key )
        throws
            UtilException
    {
        return formatColor( key, getRequiredPropValue( key ) );
    }
1023797
CssFormatter appendColor( double color, @Nullable String hint ) {
        if( !inlineMode && hint != null ) {
            output.append( hint );
        } else {
            int argb = ColorUtils.argb( color );
            output.append( '#' );
            appendHex( argb, 6 );
        }
        return this;
    }
22907
function toColorfulString(result) {
	var color;
	if (!result) {
		return '';
	}
	if (result.color == null) {
		return result.value;
	}
	color = result.color;
	return '<font color="' + color + '">' + result.value + '<\/font>';
}
809446
public static void writeHtmlColor(int color, Appendable out) throws IOException {
		out.append('#');
		out.append(getHex(color>>>20));
		out.append(getHex(color>>>16));
		out.append(getHex(color>>>12));
		out.append(getHex(color>>>8));
		out.append(getHex(color>>>4));
		out.append(getHex(color));
	}
439839
@NonNull
    public static SpannableString getColorText(@NonNull CharSequence content, int start, int end, @ColorInt int color) {
        SpannableString stringSpan = new SpannableString(content);
        stringSpan.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return stringSpan;
    }
142503
def color(string, status=True, warning=False, bold=True):
    
    attr = []
    if status:
        # green
        attr.append('32')
    if warning:
        # red
        attr.append('31')
    if bold:
        attr.append('1')
    return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string)