From 197086c857ba331630ce513788fd87f8120557e9 Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Wed, 18 Sep 2024 23:06:23 +0100 Subject: [PATCH] Remove unused file --- worldtimezone/data.py | 77 ------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 worldtimezone/data.py diff --git a/worldtimezone/data.py b/worldtimezone/data.py deleted file mode 100644 index 55c1916..0000000 --- a/worldtimezone/data.py +++ /dev/null @@ -1,77 +0,0 @@ -import json - -import pytz - -FILE_INFO = ".data/tz_v2.json" - - -class Data: - def __init__(self): - try: - with open(FILE_INFO) as f: - file = json.load(f) - except FileNotFoundError: - with open(FILE_INFO, mode="w") as f: - file = {} - json.dump(file, f) - self._data = file - - def get_guilds_list(self) -> list: - return list(self._data) - - def get_member(self, guild_id, user_id) -> dict: - guild_id = f"{guild_id}" - user_id = f"{user_id}" - if guild_id not in self._data: - return {} - if user_id not in self._data[guild_id]["members"]: - return {} - member = self._data[guild_id]["members"][user_id] - return member - - def get_members_list(self, guild_id) -> list: - guild_id = f"{guild_id}" - if guild_id not in self._data: - return [] - if "members" not in self._data[guild_id]: - return [] - return list(self._data[guild_id]["members"].keys()) - - def set_member_tz(self, guild_id, user_id, tz) -> str: - if tz not in pytz.all_timezones: - return False - guild_id = f"{guild_id}" - user_id = f"{user_id}" - tz = f"{tz}" - if guild_id not in self._data: - self._data[guild_id] = {} - if "members" not in self._data[guild_id]: - self._data[guild_id]["members"] = {} - if user_id not in self._data[guild_id]["members"]: - self._data[guild_id]["members"][user_id] = {} - self._data[guild_id]["members"][user_id]["tz"] = tz - with open(FILE_INFO, mode="w") as f: - json.dump(self._data, f) - return True - - def set_world_clock(self, guild_id, channel_id, message_id) -> bool: - guild_id = f"{guild_id}" - channel_id = f"{channel_id}" - message_id = f"{message_id}" - if guild_id not in self._data: - self._data[guild_id] = {} - if "worldclockchannel" not in self._data[guild_id]: - self._data[guild_id]["worldclockchannel"] = {} - self._data[guild_id]["worldclockchannel"]["channel_id"] = channel_id - self._data[guild_id]["worldclockchannel"]["message_id"] = message_id - with open(FILE_INFO, mode="w") as f: - json.dump(self._data, f) - return True - - def get_world_clock(self, guild_id) -> dict: - guild_id = f"{guild_id}" - if guild_id not in self._data: - return {} - if "worldclockchannel" not in self._data[guild_id]: - return {} - return self._data[guild_id]["worldclockchannel"]