initial commit
This commit is contained in:
30
models/image.py
Normal file
30
models/image.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from dataclasses import dataclass
|
||||
import uuid
|
||||
|
||||
@dataclass
|
||||
class Image:
|
||||
type: int
|
||||
extension: str
|
||||
permanent: bool = False
|
||||
id: str | None = None
|
||||
|
||||
def __post_init__(self):
|
||||
if self.id is None:
|
||||
self.id = str(uuid.uuid4())
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, d: dict):
|
||||
return cls(
|
||||
id=d.get('id'),
|
||||
type=d.get('type'),
|
||||
permanent=d.get('permanent', False),
|
||||
extension=d.get('extension')
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'permanent': self.permanent,
|
||||
'extension': self.extension
|
||||
}
|
||||
Reference in New Issue
Block a user