Class that contains colors used for TorBot in terminal and a method that adds color to a string. Attributes: message (string): Message to be wrapped in color. selected (string): Color to be displayed.
| 23 | |
| 24 | |
| 25 | class color: |
| 26 | """ |
| 27 | Class that contains colors used for TorBot in terminal and a method |
| 28 | that adds color to a string. |
| 29 | |
| 30 | Attributes: |
| 31 | message (string): Message to be wrapped in color. |
| 32 | selected (string): Color to be displayed. |
| 33 | """ |
| 34 | |
| 35 | def __init__(self, message, selected): |
| 36 | """Initialise color object with specified text and selected color.""" |
| 37 | self._msg = message |
| 38 | self._color = COLORS[selected] |
| 39 | |
| 40 | def __str__(self): |
| 41 | return self._color + self._msg + COLORS['end'] |
| 42 | |
| 43 | def __add__(self, other): |
| 44 | return str(self) + other |
| 45 | |
| 46 | def __radd__(self, other): |
| 47 | return other + str(self) |
no outgoing calls
no test coverage detected