From cd44abdc4df887e1e9ed70e510560fc26e62f97e Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Thu, 15 Aug 2019 20:42:32 +0100 Subject: autopep8 extra/colour_picker.py --- extra/colour_picker.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'extra') diff --git a/extra/colour_picker.py b/extra/colour_picker.py index b2a48ab2..374de4d0 100755 --- a/extra/colour_picker.py +++ b/extra/colour_picker.py @@ -91,9 +91,10 @@ black_______ dark_gray___ light_gray__ white_______ """ ATTR_RE = re.compile("(?P[ \n]*)(?P[^ \n]+)") -SHORT_ATTR = 4 # length of short high-colour descriptions which may +SHORT_ATTR = 4 # length of short high-colour descriptions which may # be packed one after the next + def parse_chart(chart, convert): """ Convert string chart into text markup with the correct attributes. @@ -114,7 +115,7 @@ def parse_chart(chart, convert): if attrtext: elen = SHORT_ATTR entry = entry[SHORT_ATTR:].strip() - else: # try the whole thing + else: # try the whole thing attrtext = convert(entry.strip()) assert attrtext, "Invalid palette entry: %r" % entry elen = len(entry) @@ -123,6 +124,7 @@ def parse_chart(chart, convert): out.append((attr, text.ljust(elen))) return out + def foreground_chart(chart, background, colors): """ Create text markup for a foreground colour chart @@ -139,6 +141,7 @@ def foreground_chart(chart, background, colors): return attr, entry return parse_chart(chart, convert_foreground) + def background_chart(chart, foreground, colors): """ Create text markup for a background colour chart @@ -157,9 +160,9 @@ def background_chart(chart, foreground, colors): return None # fix 8 <= colour < 16 if colors > 16 and attr.background_basic and \ - attr.background_number >= 8: + attr.background_number >= 8: # use high-colour with same number - entry = 'h%d'%attr.background_number + entry = 'h%d' % attr.background_number attr = urwid.AttrSpec(foreground, entry, colors) return attr, entry return parse_chart(chart, convert_background) @@ -226,33 +229,32 @@ def main(): mode_rb("Monochrome", 1), mode_rb("16-Color", 16, True), mode_rb("88-Color", 88), - mode_rb("256-Color", 256),]), + mode_rb("256-Color", 256)]), urwid.Pile([ fcs(urwid.RadioButton(chart_radio_buttons, - "Foreground Colors", True, on_chart_change)), + "Foreground Colors", True, on_chart_change)), fcs(urwid.RadioButton(chart_radio_buttons, - "Background Colors")), + "Background Colors")), urwid.Divider(), fcs(urwid.Button("Exit", click_exit)), ]), - ]),'panel') + ]), 'panel') ]) chart_offset = len(lb) lb.extend([ - urwid.Divider() # placeholder for the chart + urwid.Divider() # placeholder for the chart ]) - set_mode(16, True) # displays the chart + set_mode(16, True) # displays the chart def unhandled_input(key): - if key in ('Q','q','esc'): + if key in ('Q', 'q', 'esc'): raise urwid.ExitMainLoop() urwid.MainLoop(urwid.ListBox(lb), screen=screen, - unhandled_input=unhandled_input).run() + unhandled_input=unhandled_input).run() + if __name__ == "__main__": main() - - -- cgit v1.2.3