WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
2 changed files with 5 additions and 2 deletions
Showing only changes of commit ff66006b8a - Show all commits

View file

@ -29,10 +29,10 @@ class Change(AuroraBaseModel):
@classmethod @classmethod
def from_dict(cls, bot: Red, data: dict) -> "Change": def from_dict(cls, bot: Red, data: dict) -> "Change":
logger.trace("Creating Change from dict (%s): %s", type(data), data) logger.verbose("Creating Change from dict (%s): %s", type(data), data)
if isinstance(data, str): if isinstance(data, str):
data = json.loads(data) data = json.loads(data)
logger.trace("Change data was a string, converted to dict: %s", data) logger.verbose("Change data was a string, converted to dict: %s", data)
if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta): if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta):
hours, minutes, seconds = map(int, data["duration"].split(':')) hours, minutes, seconds = map(int, data["duration"].split(':'))
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds) duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)

View file

@ -162,6 +162,7 @@ class Moderation(AuroraGuildModel):
@classmethod @classmethod
def from_dict(cls, bot: Red, data: dict) -> "Moderation": def from_dict(cls, bot: Red, data: dict) -> "Moderation":
logger.verbose("Creating Moderation from dict (%s): %s", type(data), data)
return cls(bot=bot, **data) return cls(bot=bot, **data)
@classmethod @classmethod
@ -208,6 +209,8 @@ class Moderation(AuroraGuildModel):
@classmethod @classmethod
def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]: def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]:
from ..utilities.database import connect from ..utilities.database import connect
logger.trace("Executing query: %s", query)
logger.trace("With parameters: %s", parameters)
if not parameters: if not parameters:
parameters = () parameters = ()
if not cursor: if not cursor: