Skip to content

Commit d962762

Browse files
committed
chore: Форматирование кода
1 parent 0ff8782 commit d962762

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

db.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def login_user(self, login: str, password: str) -> bool:
5858
self._current_user_login = user[1]
5959
self._save_session()
6060
from utils import data_manager
61+
6162
data_manager.update_current_user(self._current_user_id)
6263
return True
6364
return False
@@ -94,6 +95,7 @@ def logout(self):
9495
self._current_user_login = None
9596
self._delete_session()
9697
from utils import data_manager
98+
9799
data_manager.update_current_user(None)
98100

99101
def _save_session(self):

utils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ class GameHistoryManager:
6464
def __init__(self):
6565
self.data_path = get_data_path()
6666
self.current_user_id = None
67-
67+
6868
def _get_user_history_path(self, user_id: int) -> Path:
6969

7070
user_dir = self.data_path / f"user_{user_id}"
7171
user_dir.mkdir(exist_ok=True)
7272
return user_dir / "last_games.txt"
73-
73+
7474
def set_current_user(self, user_id: int | None):
7575

7676
self.current_user_id = user_id
@@ -83,10 +83,10 @@ def get_last_games(self) -> list[str]:
8383

8484
if self.current_user_id is None:
8585
return []
86-
86+
8787
path = self._get_user_history_path(self.current_user_id)
8888
try:
89-
with open(path, 'r', encoding='utf-8') as f:
89+
with open(path, "r", encoding="utf-8") as f:
9090
return [game for game in f.read().split("\n") if game.strip()]
9191
except FileNotFoundError:
9292
return []
@@ -95,7 +95,7 @@ def add_game(self, game_name: str):
9595

9696
if self.current_user_id is None:
9797
return
98-
98+
9999
games = self.get_last_games()
100100
# Удаляем дубликат и добавляем в начало
101101
games = [game for game in games if game != game_name]
@@ -108,19 +108,19 @@ def _save_games(self, games: list[str]):
108108

109109
if self.current_user_id is None:
110110
return
111-
111+
112112
path = self._get_user_history_path(self.current_user_id)
113113
content = "\n".join(game for game in games if game.strip())
114-
with open(path, 'w', encoding='utf-8') as f:
114+
with open(path, "w", encoding="utf-8") as f:
115115
f.write(content)
116116

117117
def clear_history(self):
118118

119119
if self.current_user_id is None:
120120
return
121-
121+
122122
path = self._get_user_history_path(self.current_user_id)
123-
with open(path, 'w', encoding='utf-8') as f:
123+
with open(path, "w", encoding="utf-8") as f:
124124
f.write("")
125125

126126

@@ -155,7 +155,7 @@ def __init__(self):
155155
self.history = GameHistoryManager()
156156
self.settings = SettingsManager()
157157
self.session = SessionManager()
158-
158+
159159
user_id, _ = self.session.load_session()
160160
self.history.set_current_user(user_id)
161161

@@ -176,7 +176,7 @@ def set_theme(self, theme):
176176

177177
def update_setting(self, key, value):
178178
self.settings.update_setting(key, value)
179-
179+
180180
def update_current_user(self, user_id: int | None):
181181
self.history.set_current_user(user_id)
182182

0 commit comments

Comments
 (0)