Return the string wrapped with the appropriate styling escape sequences.

    Args:
      str_ (str): The string to be wrapped.
      fore_color (str, optional): Any foreground color supported by the
        `Colorama`_ module.
      back_color (str, optional): Any background color supported by the
        `Colorama`_ module.
      styles (list of str, optional): Any styles supported by the `Colorama`_
        module.

    Returns:
      str: The string styled with the appropriate escape sequences.

    .. _Colorama:
        https://pypi.python.org/pypi/colorama

def _color(str_, fore_color=None, back_color=None, styles=None):
    """ Return the string wrapped with the appropriate styling escape sequences.

    Args:
      str_ (str): The string to be wrapped.
      fore_color (str, optional): Any foreground color supported by the
        `Colorama`_ module.
      back_color (str, optional): Any background color supported by the
        `Colorama`_ module.
      styles (list of str, optional): Any styles supported by the `Colorama`_
        module.

    Returns:
      str: The string styled with the appropriate escape sequences.

    .. _Colorama:
        https://pypi.python.org/pypi/colorama
    """
    # TODO: Colorama is documented to work on Windows and trivial test case
    # proves this to be the case, but it doesn't work in Rez.  If the initialise
    # is called in sec/rez/__init__.py then it does work, however as discussed
    # in the following comment this is not always desirable.  So until we can
    # work out why we forcibly turn it off.
    if not config.get("color_enabled", False) or platform_.name == "windows":
        return str_

    # lazily init colorama. This is important - we don't want to init at startup,
    # because colorama prints a RESET_ALL character atexit. This in turn adds
    # unexpected output when capturing the output of a command run in a
    # ResolvedContext, for example.
    _init_colorama()

    colored = ""
    if not styles:
        styles = []

    if fore_color:
        colored += getattr(colorama.Fore, fore_color.upper(), '')
    if back_color:
        colored += getattr(colorama.Back, back_color.upper(), '')
    for style in styles:
        colored += getattr(colorama.Style, style.upper(), '')

    return colored + str_ + colorama.Style.RESET_ALL