@@ -9,34 +9,37 @@ def __init__(self):
99
1010 def create_txt (self ):
1111 if not self .path .exists ():
12- with open (self .path , 'w' , encoding = ' utf-8' ) as file :
13- file .write ('' )
12+ with open (self .path , "w" , encoding = " utf-8" ) as file :
13+ file .write ("" )
1414
1515 def get_last_games (self ):
1616 try :
17- with open (self .path , 'r' , encoding = ' utf-8' ) as file :
17+ with open (self .path , "r" , encoding = " utf-8" ) as file :
1818 file_data = file .read ()
1919 return file_data .split ("\n " )
2020 except FileNotFoundError :
2121 return []
2222
2323 def add_game_to_history (self , game_name ):
2424 current_games = self .get_last_games ()
25- current_games = [game for game in current_games if
26- game != game_name and game .strip ()]
25+ current_games = [
26+ game
27+ for game in current_games
28+ if game != game_name and game .strip ()
29+ ]
2730 current_games .insert (0 , game_name )
2831 current_games = current_games [:5 ]
2932 self .save_last_games (current_games )
3033
3134 def save_last_games (self , games_list ):
32- with open (self .path , 'w' , encoding = ' utf-8' ) as file :
35+ with open (self .path , "w" , encoding = " utf-8" ) as file :
3336 for game in games_list :
3437 if game .strip ():
35- file .write (game + ' \n ' )
38+ file .write (game + " \n " )
3639
3740 def clear_game_history (self ):
38- with open (self .path , 'w' , encoding = ' utf-8' ) as file :
39- file .write ('' )
41+ with open (self .path , "w" , encoding = " utf-8" ) as file :
42+ file .write ("" )
4043
4144
4245class JSONEditor :
@@ -45,33 +48,30 @@ def __init__(self):
4548
4649 def create_json (self ):
4750 if not self .path .exists ():
48- default_settings = {
49- "theme" : "dark"
50- }
51- with open (self .path , 'w' , encoding = 'utf-8' ) as file :
51+ default_settings = {"theme" : "dark" }
52+ with open (self .path , "w" , encoding = "utf-8" ) as file :
5253 json .dump (default_settings , file , indent = 4 , ensure_ascii = False )
5354
5455 def get_theme (self ):
5556 try :
56- with open (self .path , 'r' , encoding = ' utf-8' ) as file :
57+ with open (self .path , "r" , encoding = " utf-8" ) as file :
5758 settings = json .load (file )
58- return settings .get ("theme" ,
59- "dark" )
59+ return settings .get ("theme" , "dark" )
6060 except (FileNotFoundError , json .JSONDecodeError ):
6161 return "dark"
6262
6363 def update_setting (self , key , value ):
6464 try :
65- with open (self .path , 'r' , encoding = ' utf-8' ) as file :
65+ with open (self .path , "r" , encoding = " utf-8" ) as file :
6666 settings = json .load (file )
6767 except (FileNotFoundError , json .JSONDecodeError ):
6868 settings = {}
6969
7070 settings [key ] = value
7171
72- with open (self .path , 'w' , encoding = ' utf-8' ) as file :
72+ with open (self .path , "w" , encoding = " utf-8" ) as file :
7373 json .dump (settings , file , indent = 4 , ensure_ascii = False )
7474
7575
7676txt_editor = TXTEditor ()
77- json_editor = JSONEditor ()
77+ json_editor = JSONEditor ()
0 commit comments