def map_color(text, key='fontcolor'):
    """Map the text to a color.

    The text is mapped to a color.

    :param text: string of text to be mapped to a color. 'error' and
                 'fail' in the text will map to 'red'.
    :param key: in returned dictionary, the key to use that corresponds to
                the color
    :returns: A dictionary with one entry, key = color. If no color is
              associated with the text, an empty dictionary.
    """

    # If the text contains 'error'/'fail' then we'll return red...
    if 'error' in text or 'fail' in text:
        return {key: 'red'}
    else:
        return {}