more cleanup
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,12 @@ class BaseModel(ABC):
|
||||
super().__init__()
|
||||
self.load(data)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<{self.__class__.__name__}: {self.id}>"
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.__str__()
|
||||
|
||||
def load(self, data: dict) -> None:
|
||||
"""Loads `data` into the current model."""
|
||||
self.id = data.pop("id", "")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import datetime
|
||||
from typing import Union
|
||||
|
||||
|
||||
def camel_to_snake(name: str) -> str:
|
||||
@@ -12,7 +11,7 @@ def camel_to_snake(name: str) -> str:
|
||||
|
||||
def to_datetime(
|
||||
str_datetime: str, format: str = "%Y-%m-%d %H:%M:%S"
|
||||
) -> Union[datetime.datetime, str]:
|
||||
) -> datetime.datetime | str:
|
||||
str_datetime = str_datetime.split(".")[0]
|
||||
try:
|
||||
return datetime.datetime.strptime(str_datetime, format)
|
||||
|
||||
Reference in New Issue
Block a user