more cleanup
This commit is contained in:
parent
976c7e580f
commit
8363b315c3
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__()
|
super().__init__()
|
||||||
self.load(data)
|
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:
|
def load(self, data: dict) -> None:
|
||||||
"""Loads `data` into the current model."""
|
"""Loads `data` into the current model."""
|
||||||
self.id = data.pop("id", "")
|
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 re
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
|
|
||||||
def camel_to_snake(name: str) -> str:
|
def camel_to_snake(name: str) -> str:
|
||||||
@ -12,7 +11,7 @@ def camel_to_snake(name: str) -> str:
|
|||||||
|
|
||||||
def to_datetime(
|
def to_datetime(
|
||||||
str_datetime: str, format: str = "%Y-%m-%d %H:%M:%S"
|
str_datetime: str, format: str = "%Y-%m-%d %H:%M:%S"
|
||||||
) -> Union[datetime.datetime, str]:
|
) -> datetime.datetime | str:
|
||||||
str_datetime = str_datetime.split(".")[0]
|
str_datetime = str_datetime.split(".")[0]
|
||||||
try:
|
try:
|
||||||
return datetime.datetime.strptime(str_datetime, format)
|
return datetime.datetime.strptime(str_datetime, format)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user