Converts color strings into a color listing.
178579
def colors(self, value):
        
        if isinstance(value, str):
            # Must import here to avoid recursive import
            from .palettes import PALETTES

            if value not in PALETTES:
                raise YellowbrickValueError(
                    "'{}' is not a registered color palette".format(value)
                )
            self._colors = copy(PALETTES[value])
        elif isinstance(value, list):
            self._colors = value
        else:
            self._colors = list(value)
1004103
def color_str(self):
        ""
        s = self.s
        for k, v in sorted(self.atts.items()):
            # (self.atts sorted for the sake of always acting the same.)
            if k not in xforms:
                # Unsupported SGR code
                continue
            elif v is False:
                continue
            elif v is True:
                s = xforms[k](s)
            else:
                s = xforms[k](s, v)
        return s
474884
function colorLines(name, str) {
  return str
    .split('\n')
    .map(function(str) {
      return color(name, str);
    })
    .join('\n');
}
635452
def color_code(cls, color):
        
        if not isinstance(color, tuple):
            color = cls.colors[color]
        return "{:d};{}".format(color[0], str(color[1]) if len(color) == 2 else "")
435069
def _highlight(string, color):
	''''''
	if CONFIG['color']:
		if color < 8:
			return '\033[{color}m{string}\033[0m'.format(string = string, color = color+30)
		else:
			return '\033[{color}m{string}\033[0m'.format(string = string, color = color+82)
	else:
		return string
702558
function colorString(value) {
  const asColor = color(value);
  const r = asColor.r.toString(16);
  const g = asColor.g.toString(16);
  const b = asColor.b.toString(16);

  return `#${r.length === 1 ? '0' : ''}${r}${g.length === 1 ? '0' : ''}${g}${b.length === 1 ? '0' : ''}${b}`;
}
1048524
def parse_color(self, color):
        '''
        
        '''
        if color == 'none':
            return None
        return (
            int(color[1:3], 16),
            int(color[3:5], 16),
            int(color[5:7], 16))
1095910
def parse_colors(s, length=1):
    '''
    '''
    if length and length > 1:
        return parse_ctuple(s,length=length);
    if re.match('^ *{} *$'.format(isrx_s), s):
        #it's just a string.
        return [s];
    elif re.match('^ *{} *$'.format(rgbrx_s), s):
        return [eval(s)];
    else:
        return parse_ctuple(s,length=length);
70124
def parse_color(color):
    '''

    '''
    
    # Let's parse the color string
    if isinstance(color, str):
        # Try dvi names
        try:
            col = get(color)
        except ValueError:
            # String is not present
            pass

        # Try html names
        try:
            col = html_to_rgb(color)
        except ValueError:
            raise ValueError("Can't parse color string: {}'".format(color))
        
    return col
593010
def color_parts(parts):
    """"""
    return parts._replace(
        title=Fore.GREEN + parts.title + Style.RESET_ALL,
        doi=Fore.CYAN + parts.doi + Style.RESET_ALL
    )
1026921
function to_rgb(obj){
    return [obj.R, obj.G, obj.B].map(format_number).join('');
}
1207784
def code2color(color_string):
    """"""

    color_tuple = ast.literal_eval(color_string)
    color_tuple_int = map(lambda x: int(x * 255.0), color_tuple)

    return wx.Colour(*color_tuple_int)
684651
function (msg, colors) {

        if (!colors) {
            return msg;
        }

        if (typeof colors === 'string') {
            colors = [colors];
        }

        colors.forEach(function (color) {
            if (typeof colorsjs[color] === 'function') {
                msg = colorsjs[color](msg);
            }
        });

        return msg;
    }
940582
def HTMLColorToRGB(colorstring):
    
    colorstring = colorstring.strip()
    if colorstring[0] == '#':
        colorstring = colorstring[1:]
    if len(colorstring) != 6:
        raise ValueError(
            "input #{0} is not in #RRGGBB format".format(colorstring))
    r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
    r, g, b = [int(n, 16) for n in (r, g, b)]
    return (r, g, b)
801159
function(str, maxWidth) {
		var result = [];

		/* first tokenization pass - split texts and color formatting commands */
		var offset = 0;
		str.replace(this.RE_COLORS, function(match, type, name, index) {
			/* string before */
			var part = str.substring(offset, index);
			if (part.length) {
				result.push({
					type: ROT.Text.TYPE_TEXT,
					value: part
				});
			}

			/* color command */
			result.push({
				type: (type == "c" ? ROT.Text.TYPE_FG : ROT.Text.TYPE_BG),
				value: name.trim()
			});

			offset = index + match.length;
			return "";
		});

		/* last remaining part */
		var part = str.substring(offset);
		if (part.length) {
			result.push({
				type: ROT.Text.TYPE_TEXT,
				value: part
			});
		}

		return this._breakLines(result, maxWidth);
	}
1257200
def displayformat(codes=[], fg=None, bg=None):
        """"""
        if isinstance(codes, basestring):
            codes = [codes]
        else:
            codes = list(codes)
        for code in codes:
            if code not in Magic.DISPLAY.keys():
                raise ValueError("'%s' not a valid display value" % code)
        for color in (fg, bg):
            if color != None:
                if color not in Magic.COLORS.keys():
                    raise ValueError("'%s' not a valid color" % color)
        return [codes, fg, bg]
1344209
function getColors(rawData) {

    // Regular expression matching colors variables naming pattern
    var REGEX = /^dc-(.*?)[0-9]+$/;

    var content = rawData
        .filter((item) => {
            var group = item.group[0];
            return group === 'colors'
                && item.context.type === 'variable'
                && item.context.name.match(REGEX);
        })
        .map((item) => {
            // extract color name (eg. `dc-magenta10 -> magenta`)
            item.color = item.context.name.replace(REGEX, '$1');
            item.color = _.capitalize(item.color);
            return item;
        });

    // transform colors array in a object, shaped as the view layer expect
    content = _.groupBy(content, (c) => c.color );
    Object.keys(content).forEach((color) => {
        content[color] = content[color].reduce((acc, c) => {
            acc['$' + c.context.name] = c.context.value;
            return acc;
        }, {});
    });
    return content;
}