41 lines
954 B
Python
41 lines
954 B
Python
from typing import List, Optional, Tuple
|
|
|
|
from .method import Method
|
|
|
|
|
|
class Image:
|
|
__slots__ = ('path', 'hash', 'imports', )
|
|
|
|
path: Optional[str]
|
|
hash: str
|
|
imports: List[Tuple[str, Method]]
|
|
|
|
def __init__(
|
|
self,
|
|
path: Optional[str],
|
|
hash: str,
|
|
imports: List[Tuple[str, Method]],
|
|
) -> None:
|
|
self.path = path
|
|
self.hash = hash
|
|
self.imports = imports
|
|
|
|
def __repr__(self) -> str:
|
|
return f'Image({repr(self.path)}, {repr(self.hash)}, {repr(self.imports)})'
|
|
|
|
|
|
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)})'
|