MCPcopy
hub / github.com/microsoft/RD-Agent / render

Method render

rdagent/log/utils/__init__.py:35–52  ·  view source on GitHub ↗

render text by input color and style. It's not recommend that input text is already rendered.

(self, text: str, color: str = "", style: str = "")

Source from the content-addressed store, hash-verified

33 return [getattr(cls, name) for name in names]
34
35 def render(self, text: str, color: str = "", style: str = "") -> str:
36 """
37 render text by input color and style.
38 It's not recommend that input text is already rendered.
39 """
40 # This method is called too frequently, which is not good.
41 colors = self.get_all_colors()
42 # Perhaps color and font should be distinguished here.
43 if color and color in colors:
44 error_message = f"color should be in: {colors} but now is: {color}"
45 raise ValueError(error_message)
46 if style and style in colors:
47 error_message = f"style should be in: {colors} but now is: {style}"
48 raise ValueError(error_message)
49
50 text = f"{color}{text}{self.END}"
51
52 return f"{style}{text}{self.END}"
53
54 @staticmethod
55 def remove_ansi_codes(s: str) -> str:

Callers 5

get_file_descFunction · 0.80
developMethod · 0.80
evaluateMethod · 0.80
implement_one_taskMethod · 0.80
rMethod · 0.80

Calls 1

get_all_colorsMethod · 0.95

Tested by

no test coverage detected