chore(cod_api_tool.py): remove whitespace & add try except for cleaning match_info and stats files
This commit is contained in:
parent
61b910ab45
commit
dfc647e500
@ -258,14 +258,18 @@ class CodStatsManager:
|
|||||||
self.beautify_match_data(timezone, player_name)
|
self.beautify_match_data(timezone, player_name)
|
||||||
self.beautify_feed_data(timezone)
|
self.beautify_feed_data(timezone)
|
||||||
self.clean_json_files('friendFeed.json', 'eventFeed.json')
|
self.clean_json_files('friendFeed.json', 'eventFeed.json')
|
||||||
print("All data beautified successfully.")
|
print("Data beautified successfully.")
|
||||||
|
|
||||||
def beautify_stats_data(self, timezone='GMT', player_name=None):
|
def beautify_stats_data(self, timezone='GMT', player_name=None):
|
||||||
"""Beautify stats data."""
|
"""Beautify stats data."""
|
||||||
|
if player_name is None:
|
||||||
|
print("Please specify a Player Name to sort Stats")
|
||||||
|
return 0
|
||||||
|
try:
|
||||||
if player_name:
|
if player_name:
|
||||||
file_name = f'stats-{self._extract_player_name(player_name)}.json'
|
file_name = f'stats-{self._extract_player_name(player_name)}.json'
|
||||||
else:
|
# else:
|
||||||
file_name = 'stats.json'
|
# file_name = 'stats.json'
|
||||||
|
|
||||||
file_path = os.path.join(STATS_DIR, file_name)
|
file_path = os.path.join(STATS_DIR, file_name)
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
@ -290,12 +294,21 @@ class CodStatsManager:
|
|||||||
|
|
||||||
print(f"Keys sorted and replaced in {file_path}.")
|
print(f"Keys sorted and replaced in {file_path}.")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("An error occurred while processing match data.")
|
||||||
|
return 0
|
||||||
|
|
||||||
def beautify_match_data(self, timezone='GMT', player_name=None):
|
def beautify_match_data(self, timezone='GMT', player_name=None):
|
||||||
"""Beautify match data."""
|
"""Beautify match data."""
|
||||||
|
if player_name is None:
|
||||||
|
print("Please specify a Player Name to sort Match Info")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
try:
|
||||||
if player_name:
|
if player_name:
|
||||||
file_name = f'match_info-{self._extract_player_name(player_name)}.json'
|
file_name = f'match_info-{self._extract_player_name(player_name)}.json'
|
||||||
else:
|
# else:
|
||||||
file_name = 'match_info.json'
|
# file_name = 'match_info.json'
|
||||||
|
|
||||||
file_path = os.path.join(STATS_DIR, file_name)
|
file_path = os.path.join(STATS_DIR, file_name)
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
@ -317,6 +330,10 @@ class CodStatsManager:
|
|||||||
|
|
||||||
print(f"Keys replaced in {file_path}.")
|
print(f"Keys replaced in {file_path}.")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("An error occurred while processing match data.")
|
||||||
|
return 0
|
||||||
|
|
||||||
def beautify_feed_data(self, timezone='GMT', player_name=None):
|
def beautify_feed_data(self, timezone='GMT', player_name=None):
|
||||||
"""Beautify feed data files."""
|
"""Beautify feed data files."""
|
||||||
for feed_file_base in ['friendFeed.json', 'eventFeed.json']:
|
for feed_file_base in ['friendFeed.json', 'eventFeed.json']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user