Skip to content

Commit

Permalink
Lint issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
worldpeace-germany committed Jan 16, 2025
1 parent 6eb92b7 commit 6c82cae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 5 additions & 6 deletions mpf/config_players/segment_display_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Binary file not shown.
13 changes: 8 additions & 5 deletions mpf/devices/segment_display/segment_display_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def _create_characters(cls, text: str, display_size: int, collapse_dots: bool, c
use_dots_for_commas: bool, colors: List[Optional[RGBColor]]) -> 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)
Expand All @@ -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

Expand Down

0 comments on commit 6c82cae

Please sign in to comment.