From d8d7cfbc87a5c4afc38f2deb19b6d16213950449 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Sat, 1 Jun 2024 18:35:49 -0700 Subject: [PATCH] Move some lines of code (related to ouputting the online status) into `print_dict_report`. Also add hypixel to the project description sentence. --- README.md | 2 +- hypickle/Player.py | 12 ++++++------ pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3abd923..b746925 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hypickle -A script that outputs realtime stats for custom lists of friends you create. +A script that outputs realtime hypixel stats for custom lists of friends you create. ### Installation: diff --git a/hypickle/Player.py b/hypickle/Player.py index ee1d65d..ccaa4de 100644 --- a/hypickle/Player.py +++ b/hypickle/Player.py @@ -242,7 +242,7 @@ def get_stats_dict(self) -> dict[str, str | float | int]: return {'uuid': self.uuid(), 'name': self.name(), 'fkdr': self.get_fkdr(), 'star': self.get_bw_star(), 'pit_rank': self.pit_rank_string()} - def print_dict_report(self, report: dict, extra_text: str = '') -> None: + def print_dict_report(self, report: dict, output_online_status: bool = False) -> None: report = deepcopy(report) assert all(isinstance(v, (str,float,int)) for v in report.values()) possible_keys = ('name', 'fkdr', 'star', 'pit_rank', 'uuid', 'time') @@ -287,7 +287,10 @@ def print_dict_report(self, report: dict, extra_text: str = '') -> None: time_friended = date_obj.strftime('%b ') + date_obj.strftime('%d/%y').lstrip('0') print(f" friended {time_friended}".ljust(20), end='') print(recent_game_msg, end='') - print(extra_text, end='') + if output_online_status: + if is_online := self.hypixel_object().isOnline((True,)*3): + Utils.speak(f"{self.name()} is online") + print(f"this arg player is {'online' if is_online else 'offline'}", end='') if not just_uuids and (updated_json := self.hypixel_object().updated_json) is not None: print(f" (updated player json obtained {updated_json[1].strftime('%I:%M:%S %p')})", end='') print() @@ -335,10 +338,7 @@ def iterate_over_friends_for_report( if self._players_used_to_combine: assert self.root_player() for player in self._players_used_to_combine: - online_status = 'online' if player.hypixel_object().isOnline((True,)*3) else 'offline' - if online_status == 'online': - Utils.speak(f"{player.name()} is online") - player.print_dict_report(player.get_stats_dict(), f"this arg player is {online_status}") + player.print_dict_report(player.get_stats_dict(), True) print() report.setdefault('friends', []) diff --git a/pyproject.toml b/pyproject.toml index 34d9b83..957c558 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ version = "1.1.5" authors = [ { name="John Doknjas", email="jdoknjas@sfu.ca" }, ] -description = "A script that outputs realtime stats for custom lists of friends you create." +description = "A script that outputs realtime hypixel stats for custom lists of friends you create." keywords = ["hypickle", "hypixel", "pit", "bedwars", "friends", "stats", "api"] dependencies = [ "requests",