X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=9265c3cddfe6103e36eb80d3203317295fa2aae7;hb=24cc6f0ba625f217d6127fc0cee880b22a8c6cbf;hp=4e481e64ab4bfd5349569ae61e70fe36dc15060b;hpb=78a694ddcd2a6ecc8b2b1fd3c74ee2d938707305;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 4e481e6..9265c3c 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -22,7 +22,6 @@ Defines some object to handle audio file metadata """ from .simastr import SimaStr -from .track import Track class MetaException(Exception): """Generic Meta Exception""" @@ -65,8 +64,15 @@ class Meta: else: return id(self) + def __bool__(self): # empty name not possible for a valid obj + return bool(self.name) class Album(Meta): + """Info: + If a class that overrides __eq__() needs to retain the implementation of + __hash__() from a parent class, the interpreter must be told this explicitly + by setting __hash__ = .__hash__. + """ __hash__ = Meta.__hash__ def __init__(self, **kwargs): @@ -90,15 +96,15 @@ class Album(Meta): class Artist(Meta): def __init__(self, **kwargs): - self._aliases = [] + self._aliases = set() super().__init__(**kwargs) def append(self, name): - self._aliases.append(name) + self._aliases.update({name,}) @property def names(self): - return self._aliases + [self.name] + return self._aliases | {self.name,} def __add__(self, other): if isinstance(other, Artist): @@ -109,14 +115,4 @@ class Artist(Meta): else: raise NotSameArtist('different mbids: {0} and {1}'.format(self, other)) - -class TrackMB(Track): - - def __init__(self, **kwargs): - super().__init__(**kwargs) - if hasattr(self, 'musicbrainz_artistid'): - self.artist = Artist(mbid=self.musicbrainz_artistid, - name=self.artist) - # vim: ai ts=4 sw=4 sts=4 expandtab -