]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/meta.py
Deal with multi-tag for musicbrainz_albumartistid and albumartist
[mpd-sima.git] / sima / lib / meta.py
index a3efbf55fe68805e133b9ff32cdcc562791cf231..9265c3cddfe6103e36eb80d3203317295fa2aae7 100644 (file)
@@ -64,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__ = <ParentClass>.__hash__.
+    """
     __hash__ = Meta.__hash__
 
     def __init__(self, **kwargs):
@@ -89,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,4 +116,3 @@ class Artist(Meta):
                 raise NotSameArtist('different mbids: {0} and {1}'.format(self, other))
 
 # vim: ai ts=4 sw=4 sts=4 expandtab
-