'Convert a match object generated by ``color_re`` into an ansi
color code. This can be used as a handler in ``re.sub``.'

def __call__(self, match):

    (style, color, text) = match.groups()
    m = match.group(0)
    if (m == '@@'):
        return '@'
    elif (m == '@.'):
        return self.escape(0)
    elif (m == '@'):
        raise ColorParseError(("Incomplete    color    format:    '%s'    in    %s" % (m, match.string)))
    string = styles[style]
    if color:
        if (color not in colors):
            raise ColorParseError(("invalid    color    specifier:    '%s'    in    '%s'" % (color, match.string)))
        string += (';' + str(colors[color]))
    colored_text = ''
    if text:
        colored_text = (text + self.escape(0))
    return (self.escape(string) + colored_text)
