Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove locale as cogs will not start #19

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions services/profile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from config.config import BASE_URL
import time
import locale

locale.setlocale(locale.LC_ALL, 'nl_NL')

class Profile:
"""
A class to represent a Profile.
"""

def __init__(self, data: dict):
"""
Constructs all the necessary attributes for the Game object.
Parameters
----------
data : dict
The data dictionary containing all the game details.
"""
self.user = data.get('User', "N/A")
self.user_pic = f"{BASE_URL}{data.get('UserPic', '')}"
self.user_pic_unique = f"{self.user_pic}?timestamp={int(time.time())}"
Expand All @@ -28,4 +36,15 @@ def __init__(self, data: dict):
self.motto = data.get('Motto', "N/A")

def format_points(self, points: int) -> str:
return locale.format_string("%d", points, grouping=True).replace(',', '.') if points >= 10000 else str(points)
"""
Formats the points with commas as thousands separators.
Parameters
----------
points : int
The points to be formatted.
Returns
-------
str
The formatted points.
"""
return format(points, ',').replace(',', '.') if points >= 10000 else str(points)
Loading