comparison sat_frontends/jp/cmd_debug.py @ 3047:cf843dd7c345

jp (debug): new "theme" command to print colour theme according to `background` value: fix 321
author Goffi <goffi@goffi.org>
date Tue, 01 Oct 2019 22:49:11 +0200
parents fee60f17ebac
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3046:d9f328374473 3047:cf843dd7c345
185 185
186 async def start(self): 186 async def start(self):
187 self.host.bridge.register_signal("xmlLog", self.printXML, "plugin") 187 self.host.bridge.register_signal("xmlLog", self.printXML, "plugin")
188 188
189 189
190 class Theme(base.CommandBase):
191 def __init__(self, host):
192 base.CommandBase.__init__(
193 self, host, "theme", help=_("print colours used with your background")
194 )
195
196 def add_parser_options(self):
197 pass
198
199 async def start(self):
200 for attr in dir(C):
201 if not attr.startswith('A_'):
202 continue
203 color = getattr(C, attr)
204 if attr == 'A_LEVEL_COLORS':
205 # This constant contains multiple colors
206 self.disp('LEVEL COLORS: ', no_lf=True)
207 for idx, c in enumerate(color):
208 last = idx == len(color)-1
209 self.disp(c + f'LEVEL_{idx}' + A.RESET + (', ' if not last else ''), no_lf=not last)
210 else:
211 text = attr[2:]
212 self.disp(A.color(color, text))
213 self.host.quit()
214
215
190 class Debug(base.CommandBase): 216 class Debug(base.CommandBase):
191 subcommands = (Bridge, Monitor) 217 subcommands = (Bridge, Monitor, Theme)
192 218
193 def __init__(self, host): 219 def __init__(self, host):
194 super(Debug, self).__init__( 220 super(Debug, self).__init__(
195 host, "debug", use_profile=False, help=_("debugging tools") 221 host, "debug", use_profile=False, help=_("debugging tools")
196 ) 222 )