# Path: catkin_tools/terminal_color.py
# def ansi(key):
#     """Returns the escape sequence for a given ansi color key"""
#     global _ansi
#     return _ansi[key]
# 
# Path: catkin_tools/terminal_color.py
# def fmt(msg, reset=True):
#     """Replaces color annotations with ansi escape sequences"""
#     global _ansi
#     msg = msg.replace('@!', '@{boldon}')
#     msg = msg.replace('@/', '@{italicson}')
#     msg = msg.replace('@_', '@{ulon}')
#     msg = msg.replace('@|', '@{reset}')
#     t = ColorTemplate(msg)
#     return t.substitute(_ansi) + (ansi('reset') if reset else '')
# 
# Path: catkin_tools/terminal_color.py
# def sanitize(msg):
#     """Sanitizes the existing msg, use before adding color annotations"""
#     msg = msg.replace('@', '@@')
#     msg = msg.replace('{', '{{')
#     msg = msg.replace('}', '}}')
#     msg = msg.replace('@@!', '@{atexclimation}')
#     msg = msg.replace('@@/', '@{atfwdslash}')
#     msg = msg.replace('@@_', '@{atunderscore}')
#     msg = msg.replace('@@|', '@{atbar}')
#     return msg
# 
# Path: catkin_tools/terminal_color.py
# class ColorMapper(object):
# 
#     """This class encapsulates a set of human-readable format strings and the
#     functionality to convert them into colorized version.
#     """
# 
#     # This map translates more human readable format strings into colorized versions
#     default_color_translation_map = {
#         # 'output': 'colorized_output'
#         '': fmt('@!' + sanitize('') + '@|')
#     }
# 
#     def __init__(self, color_map={}):
#         """Create a color mapper with a given map.
# 
#         :param color_map: A dictionary of format strings and colorized versions
#         :type color_map: dict
#         """
#         self.color_map = ColorMapper.default_color_translation_map
#         self.color_map.update(color_map)
# 
#     def clr(self, key):
#         """Returns a colorized version of the string given.
# 
#         This is accomplished by either returning a hit from the color translation
#         map or by calling :py:func:`fmt` on the string and returning it.
# 
#         :param key: string to be colorized
#         :type key: str
#         """
#         global _color_on
#         if not _color_on:
#             return fmt(key)
#         val = self.color_map.get(key, None)
#         if val is None:
#             return fmt(key)
#         return val


from catkin_tools.terminal_color import ansi
from catkin_tools.terminal_color import fmt
from catkin_tools.terminal_color import sanitize
from catkin_tools.terminal_color import ColorMapper
# See the License for the specific language governing permissions and
# limitations under the License.

"""This module implements many of the colorization functions used by catkin build"""


# This map translates more human readable format strings into colorized versions
_color_translation_map = {
    # 'output': 'colorized_output'
    '': fmt('@!' + sanitize('') + '@|'),

    "[{package}] ==> '{cmd.cmd_str}' in '{location}'":
    fmt("[@{cf}{package}@|] @!@{bf}==>@| '@!{cmd.cmd_str}@|' @{kf}@!in@| '@!{location}@|'"),

    "Starting ==> {package}":
    fmt("Starting @!@{gf}==>@| @!@{cf}{package}@|"),

    "[{package}] {msg}":
    fmt("[@{cf}{package}@|] {msg}"),

    "[{package}] <== '{cmd.cmd_str}' failed with return code '{retcode}'":
    fmt("[@{cf}{package}@|] @!@{rf}<==@| '@!{cmd.cmd_str}@|' @{rf}failed with return code@| '@!{retcode}@|'"),

    "[{package}] <== '{cmd.cmd_str}' finished with return code '{retcode}'":
    fmt("[@{cf}{package}@|] @{gf}<==@| '@!{cmd.cmd_str}@|' finished with return code '@!{retcode}@|'"),

    "Finished <== {package:<":
    fmt("@!@{kf}Finished@| @{gf}<==@| @{cf}{package:<").rstrip(ansi('reset')),

    "Failed <== {package:<":

# Path: catkin_tools/terminal_color.py
# def ansi(key):
#     """Returns the escape sequence for a given ansi color key"""
#     global _ansi
#     return _ansi[key]
# 
# Path: catkin_tools/terminal_color.py
# def fmt(msg, reset=True):
#     """Replaces color annotations with ansi escape sequences"""
#     global _ansi
#     msg = msg.replace('@!', '@{boldon}')
#     msg = msg.replace('@/', '@{italicson}')
#     msg = msg.replace('@_', '@{ulon}')
#     msg = msg.replace('@|', '@{reset}')
#     t = ColorTemplate(msg)
#     return t.substitute(_ansi) + (ansi('reset') if reset else '')
# 
# Path: catkin_tools/terminal_color.py
# def sanitize(msg):
#     """Sanitizes the existing msg, use before adding color annotations"""
#     msg = msg.replace('@', '@@')
#     msg = msg.replace('{', '{{')
#     msg = msg.replace('}', '}}')
#     msg = msg.replace('@@!', '@{atexclimation}')
#     msg = msg.replace('@@/', '@{atfwdslash}')
#     msg = msg.replace('@@_', '@{atunderscore}')
#     msg = msg.replace('@@|', '@{atbar}')
#     return msg
# 
# Path: catkin_tools/terminal_color.py
# class ColorMapper(object):
# 
#     """This class encapsulates a set of human-readable format strings and the
#     functionality to convert them into colorized version.
#     """
# 
#     # This map translates more human readable format strings into colorized versions
#     default_color_translation_map = {
#         # 'output': 'colorized_output'
#         '': fmt('@!' + sanitize('') + '@|')
#     }
# 
#     def __init__(self, color_map={}):
#         """Create a color mapper with a given map.
# 
#         :param color_map: A dictionary of format strings and colorized versions
#         :type color_map: dict
#         """
#         self.color_map = ColorMapper.default_color_translation_map
#         self.color_map.update(color_map)
# 
#     def clr(self, key):
#         """Returns a colorized version of the string given.
# 
#         This is accomplished by either returning a hit from the color translation
#         map or by calling :py:func:`fmt` on the string and returning it.
# 
#         :param key: string to be colorized
#         :type key: str
#         """
#         global _color_on
#         if not _color_on:
#             return fmt(key)
#         val = self.color_map.get(key, None)
#         if val is None:
#             return fmt(key)
#         return val


# Path: catkin_tools/verbs/catkin_build/color.py
from catkin_tools.terminal_color import ansi
from catkin_tools.terminal_color import fmt
from catkin_tools.terminal_color import sanitize
from catkin_tools.terminal_color import ColorMapper

# See the License for the specific language governing permissions and
# limitations under the License.

"""This module implements many of the colorization functions used by catkin build"""


# This map translates more human readable format strings into colorized versions
_color_translation_map = {
    # 'output': 'colorized_output'
    '': fmt('@!' + sanitize('') + '@|'),

    "[{package}] ==> '{cmd.cmd_str}' in '{location}'":
    fmt("[@{cf}{package}@|] @!@{bf}==>@| '@!{cmd.cmd_str}@|' @{kf}@!in@| '@!{location}@|'"),

    "Starting ==> {package}":
    fmt("Starting @!@{gf}==>@| @!@{cf}{package}@|"),

    "[{package}] {msg}":
    fmt("[@{cf}{package}@|] {msg}"),

    "[{package}] <== '{cmd.cmd_str}' failed with return code '{retcode}'":
    fmt("[@{cf}{package}@|] @!@{rf}<==@| '@!{cmd.cmd_str}@|' @{rf}failed with return code@| '@!{retcode}@|'"),

    "[{package}] <== '{cmd.cmd_str}' finished with return code '{retcode}'":
    fmt("[@{cf}{package}@|] @{gf}<==@| '@!{cmd.cmd_str}@|' finished with return code '@!{retcode}@|'"),

    "Finished <== {package:<":
    fmt("@!@{kf}Finished@| @{gf}<==@| @{cf}{package:<").rstrip(ansi('reset')),

    "Failed <== {package:<":

    fmt("@!@{rf}Failed@|   @{gf}<==@| @{cf}{package:<").rstrip(ansi('reset')),