Method: pylint.reporters.text._get_ansi_code
Calls: 174, Exceptions: 0, Paths: 1Back
Path 1: 174 calls (1.0)
MessageStyle (174)
'\x1b[1;31m' (168) '\x1b[35m' (4) '\x1b[7;33m' (2)
1def _get_ansi_code(msg_style: MessageStyle) -> str:
2 """Return ANSI escape code corresponding to color and style.
3
4 :param msg_style: the message style
5
6 :raise KeyError: if a nonexistent color or style identifier is given
7
8 :return: the built escape code
9 """
10 ansi_code = [ANSI_STYLES[effect] for effect in msg_style.style]
11 if msg_style.color:
12 if msg_style.color.isdigit():
13 ansi_code.extend(["38", "5"])
14 ansi_code.append(msg_style.color)
15 else:
16 ansi_code.append(ANSI_COLORS[msg_style.color])
17 if ansi_code:
18 return ANSI_PREFIX + ";".join(ansi_code) + ANSI_END
19 return ""