32 lines
721 B
Python
32 lines
721 B
Python
from typing import Optional
|
|
|
|
|
|
class Image:
|
|
__slots__ = ('path', 'hash', )
|
|
|
|
path: Optional[str]
|
|
hash: str
|
|
|
|
def __init__(self, path: Optional[str], hash: str) -> None:
|
|
self.path = path
|
|
self.hash = hash
|
|
|
|
def __repr__(self) -> str:
|
|
return f'Image({repr(self.path)}, {repr(self.hash)})'
|
|
|
|
|
|
class ImageReference(Image):
|
|
__slots__ = ('name', )
|
|
|
|
name: str
|
|
|
|
def __init__(self, name: str) -> None:
|
|
# Intentionally do not call super()
|
|
# This will cause AttributeError exceptions when someone
|
|
# tries to access an image that's only a reference
|
|
|
|
self.name = name
|
|
|
|
def __repr__(self) -> str:
|
|
return f'ImageReference({repr(self.name)})'
|