Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.

Commit ddf9b7c

Browse files
author
User Name
committed
Applies Azaroths fix of players name that have accent.
1 parent 87a31b5 commit ddf9b7c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/renderer/goal.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from PIL import Image, ImageFont, ImageDraw, ImageSequence
2-
from utils import center_text, convert_date_format
2+
from utils import center_text, convert_date_format,strip_accents
33
from renderer.matrix import MatrixPixels
44
import debug
55

6+
67
"""
78
Show the details of a goal:
89
- Time of the goal and which period
@@ -72,13 +73,13 @@ def draw_scorer(self):
7273

7374
self.matrix.draw_text(
7475
(8, 20),
75-
self.scorer["info"]["firstName"]["default"].upper(),
76+
strip_accents(self.scorer["info"]["firstName"]["default"].upper()),
7677
font=self.font,
7778
fill=(255,255,255)
7879
)
7980
self.matrix.draw_text(
8081
(8, 26),
81-
self.scorer["info"]["lastName"]["default"].upper(),
82+
strip_accents(self.scorer["info"]["lastName"]["default"].upper()),
8283
font=self.font,
8384
fill=(255,255,255)
8485
)
@@ -94,7 +95,7 @@ def draw_details(self):
9495

9596
scorer_name_coord = self.matrix.draw_text(
9697
(1, 8),
97-
self.scorer["info"]["lastName"]["default"].upper(),
98+
strip_accents(self.scorer["info"]["lastName"]["default"].upper()),
9899
font=self.font,
99100
fill=(255, 255, 255)
100101
)
@@ -118,7 +119,7 @@ def draw_details(self):
118119
for i in range(len(self.assists)):
119120
assist_name_coord = self.matrix.draw_text(
120121
(1, assists_y_pos),
121-
self.assists[i]["info"]["lastName"]["default"].upper(),
122+
strip_accents(self.assists[i]["info"]["lastName"]["default"].upper()),
122123
font=self.font,
123124
fill=(255, 255, 255)
124125
)
@@ -173,4 +174,4 @@ def draw_hashtag(self):
173174
self.layout.scorer_info.hashtag_dots,
174175
pixels,
175176
(10, 10)
176-
)
177+
)

src/renderer/penalty.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from PIL import Image, ImageFont, ImageDraw, ImageSequence
2-
from utils import center_text, convert_date_format
2+
from utils import center_text, convert_date_format, strip_accents
33
from renderer.matrix import MatrixPixels
44
import debug
55
from nhl_api.info import TeamInfo
@@ -67,7 +67,7 @@ def draw_penalty(self):
6767

6868
self.matrix.draw_text_layout(
6969
self.layout.last_name,
70-
self.player["lastName"]["default"]
70+
strip_accents(self.player["lastName"]["default"])
7171
)
7272
self.matrix.draw_text_layout(
7373
self.layout.minutes,
@@ -102,4 +102,4 @@ def draw_hashtag(self):
102102
self.layout.hashtag_dots,
103103
pixels,
104104
(32, 10)
105-
)
105+
)

src/utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,6 @@ def round_normal(n, decimals=0):
280280
multiplier = 10 ** decimals
281281
value = math.floor(n * multiplier + 0.5) / multiplier
282282
return int(value) if decimals == 0 else value
283+
284+
def strip_accents(str):
285+
return "".join(c for c in unicodedata.normalize("NFD", str) if not unicodedata.combining(c))

0 commit comments

Comments
 (0)