From 6c82cae940642bd59403b5ce4ad76f0dd8f852f7 Mon Sep 17 00:00:00 2001 From: worldpeace-germany Date: Thu, 16 Jan 2025 17:43:43 +0100 Subject: [PATCH] Lint issues fixed --- mpf/config_players/segment_display_player.py | 11 +++++------ .../segment_display/.segment_display.py.kate-swp | Bin 0 -> 1980 bytes .../segment_display/segment_display_text.py | 13 ++++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 mpf/devices/segment_display/.segment_display.py.kate-swp diff --git a/mpf/config_players/segment_display_player.py b/mpf/config_players/segment_display_player.py index 37c7e110a..27bfb2e2b 100644 --- a/mpf/config_players/segment_display_player.py +++ b/mpf/config_players/segment_display_player.py @@ -106,14 +106,13 @@ def _remove(self, instance_dict, key, display): del instance_dict[display][key] def clear_context(self, context): + """Remove all texts. Ignore what keys are available, that will be checked later in the segment display code. + Especially important for update_method replace since there are no keys.""" - # Remove all texts. Ignore what keys are available, that will be checked later in the segment display code. - # Especially important for update_method replace since there are no keys. + instance_dict = self._get_instance_dict(context) # key of the dict is the display, the value is another dict - instance_dict = self._get_instance_dict(context) # key of the dict is the display, the value is another dict - - for display, keys_dict in instance_dict.items(): # keys_dict key is the show key, the value is a boolean (with yet unknown usage) - if keys_dict: #depending on the situation the keys_dict might be empty, still need to clear the display + for display, keys_dict in instance_dict.items(): # keys_dict key is the show key, value is bool(unknown usage) + if keys_dict: #depending on the situation the keys_dict might be empty, still need to clear the display for key in dict(keys_dict).keys(): display.clear_segment_display(key) if instance_dict[display][key] is not True: diff --git a/mpf/devices/segment_display/.segment_display.py.kate-swp b/mpf/devices/segment_display/.segment_display.py.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..c940cf7dff1e4a5da2b6ac452f904686cb9e3b32 GIT binary patch literal 1980 zcmaKt&1w`u5XWc1LsSSc#uzn$Mh~78@e{i?eAUzHj*%d*Lb{i+PbPJbBgZ)}#~`qgV$ zmQ5X7d-eLqpT7rhXZ8n6`v+g2-kp9|Jg`X5?4DWYVt(W=*M1XSIgCECy=O*rB`;cT zll}j*ytLeUDC9+6tXiPQ#oW_3V@-tCN+%~Q+^J7C51(>m(vj1SOgVDKk!eTHIx^$P zIY-Vra>0>VAv8iOg=nP^trVh_LbOtdRtnKdAzCR!D}`vK5UmuVl|p=_b4JtulpNM< zYX-z+2%F2gaXK0|-So_ow2Kh!B1F3g(Jn%?ixBN1M7s#lE<&`65bYvFy9m)PLbQtz zTGD*X_(kpWmEb+Dz4-Mu*@vHBolM@E8EZ~j-FEWgiRHXG+Bo^%Y~C#O9&*Exn~roH zS#V_0ktIiN3He~2>Vc>pi0XlK%~BN*)dNvI5Y+=wJs*vz9*F9Js2)hyEa`zPIHG#U zQ9TgV^T~+nfv6sc>Vc>pi0XkXnkCH;)dNX-nA<%w*5x==dvQ*`L List[DisplayCharacter]: """Create characters from text and color them. - Dots and commas are embedded on the fly. - - Text will be right aligned on the display, thus if text is shorter than display spaces will be padded before the text - - If list of colors is less than the display size then all white will be used, if only one color is given that will be used for the full display + - Text will be right aligned on the display, if text is shorter than display spaces add on the left + - If list of colors is less than the display size then all white will be used, + - If only one color is given that will be used for the full display """ char_list = [] uncolored_chars = cls._embed_dots_and_commas(text, collapse_dots, collapse_commas, use_dots_for_commas) @@ -88,18 +89,20 @@ def _create_characters(cls, text: str, display_size: int, collapse_dots: bool, c #TODO: Log that colors were adjusted to white as default colors = [RGBColor("white")] * display_size - # ensure list is the same size as the segment display (cut off on left if too long or right justify characters if too short) + # ensure list is the same size as the segment display + # cut off on left if too long or right justify characters if too short current_length = len(uncolored_chars) if current_length > display_size: for _ in range(current_length - display_size): - uncolored_chars.pop(0) # remove very left char of array if too long + uncolored_chars.pop(0) # remove very left char of array if too long elif current_length < display_size: for _ in range(display_size - current_length): uncolored_chars.insert(0, (SPACE_CODE, False, False)) for i, char in enumerate(uncolored_chars): color = colors[i] - char_list.append(DisplayCharacter(char[0], char[1], char[2], color)) #0: char code 1: char_has_dot 2: char_has_comma + #0: char code 1: char_has_dot 2: char_has_comma + char_list.append(DisplayCharacter(char[0], char[1], char[2], color)) return char_list