Skip to content

Commit

Permalink
cleaned up guilddb
Browse files Browse the repository at this point in the history
  • Loading branch information
nfearnley committed May 21, 2024
1 parent 2a47851 commit 6e3bfec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sizebot/lib/guilddb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ def fromJSON(cls, jsondata: Any) -> Guild:
return guilddata


def get_guild_path(guildid: int) -> Path:
def _get_guild_path(guildid: int) -> Path:
return paths.guilddbpath / f"{guildid}"


def get_guild_data_path(guildid: int) -> Path:
return get_guild_path(guildid) / "guild.json"
def _get_guild_data_path(guildid: int) -> Path:
return _get_guild_path(guildid) / "guild.json"


def save(guilddata: Guild):
guildid = guilddata.id
if guildid is None:
raise errors.CannotSaveWithoutIDException
path = get_guild_data_path(guildid)
path = _get_guild_data_path(guildid)
path.parent.mkdir(exist_ok = True, parents = True)
jsondata = guilddata.toJSON()
with open(path, "w") as f:
json.dump(jsondata, f, indent = 4)


def load(guildid: int) -> Guild:
path = get_guild_data_path(guildid)
path = _get_guild_data_path(guildid)
try:
with open(path, "r") as f:
jsondata = json.load(f)
Expand All @@ -109,7 +109,7 @@ def load_or_create(guildid: int) -> Guild:


def delete(guildid: int):
path = get_guild_path(guildid)
path = _get_guild_path(guildid)
path.unlink(missing_ok = True)


Expand Down

0 comments on commit 6e3bfec

Please sign in to comment.