feat: removed distracting code
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful

This commit is contained in:
Hazel 2024-06-07 11:15:23 +02:00
parent 01dffc2443
commit eef3ea7f07

View File

@ -41,7 +41,7 @@ class Artwork:
def search_variant(self, url: str) -> Optional[ArtworkVariant]: def search_variant(self, url: str) -> Optional[ArtworkVariant]:
if url is None: if url is None:
return None return None
for variant in self.variants: for variant in self.variants:
if url in variant: if url in variant:
return variant return variant
@ -61,6 +61,12 @@ class Artwork:
variant.url = url variant.url = url
variant.__dict__.update(kwargs) variant.__dict__.update(kwargs)
@property
def url(self) -> Optional[str]:
if len(self.variants) <= 0:
return None
return self.variants[0].url
class ArtworkCollection: class ArtworkCollection:
""" """
@ -123,6 +129,23 @@ class ArtworkCollection:
self._data.append(value) self._data.append(value)
return return
def __merge__(self, other: ArtworkCollection, **kwargs) -> None:
self.parent_artworks.update(other.parent_artworks)
for key, value in other._variant_mapping.items():
if key not in self._variant_mapping:
self._variant_mapping[key] = value
def __hash__(self) -> int:
return id(self)
def __iter__(self) -> Generator[Artwork, None, None]:
yield from self._data
def get_urls(self) -> Generator[str, None, None]:
yield from (artwork.url for artwork in self._data if artwork.url is not None)
"""
@property @property
def flat_empty(self) -> bool: def flat_empty(self) -> bool:
return len(self._variant_mapping.keys()) <= 0 return len(self._variant_mapping.keys()) <= 0
@ -138,18 +161,5 @@ class ArtworkCollection:
def get_variant_name(self, variant: ArtworkVariant) -> str: def get_variant_name(self, variant: ArtworkVariant) -> str:
return f"artwork_{variant['width']}x{variant['height']}_{hash_url(variant['url']).replace('/', '_')}" return f"artwork_{variant['width']}x{variant['height']}_{hash_url(variant['url']).replace('/', '_')}"
"""
def __merge__(self, other: ArtworkCollection, **kwargs) -> None:
self.parent_artworks.update(other.parent_artworks)
for key, value in other._variant_mapping.items():
if key not in self._variant_mapping:
self._variant_mapping[key] = value
def __hash__(self) -> int:
return id(self)
def __iter__(self) -> Generator[ArtworkVariant, None, None]:
yield from self._variant_mapping.values()