]> kaliko git repositories - mpd-sima.git/commitdiff
Merge Album type in Meta module
authorkaliko <efrim@azylum.org>
Tue, 28 Jan 2014 18:12:23 +0000 (19:12 +0100)
committerkaliko <efrim@azylum.org>
Tue, 28 Jan 2014 18:12:23 +0000 (19:12 +0100)
sima/client.py
sima/lib/album.py [deleted file]
sima/lib/meta.py

index b3c9591e28b7d949885d05ff68feac0a95a7c28f..f1d2b8f2cde6e68e8669bcdac4876324fe674c5f 100644 (file)
@@ -21,7 +21,7 @@ except ImportError as err:
 # local import
 from .lib.player import Player
 from .lib.track import Track
-from .lib.album import Album
+from .lib.meta import Album
 from .lib.simastr import SimaStr
 
 
@@ -57,7 +57,7 @@ def blacklist(artist=False, album=False, track=False):
     return decorated
 
 class PlayerClient(Player):
-    """MPC Client
+    """MPD Client
     From python-musicpd:
         _fetch_nothing  …
         _fetch_item     single str
@@ -69,7 +69,7 @@ class PlayerClient(Player):
         _fetch_songs    list of dict, especially tracks
         _fetch_plugins,
     TODO: handle exception in command not going through _client_wrapper() (ie.
-          find_aa, remove…)
+          remove…)
     """
     database = None  # sima database (history, blaclist)
 
diff --git a/sima/lib/album.py b/sima/lib/album.py
deleted file mode 100644 (file)
index 8695aa4..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from .track import Track
-
-class MetaException(Exception):
-    pass
-
-class Meta:
-
-    def __init__(self, **kwargs):
-        self.name = None
-        self.mbid = None
-        if 'name' not in kwargs:
-            raise MetaException('need at least a "name" argument')
-        self.__dict__.update(kwargs)
-
-    def __repr__(self):
-        fmt = '{0}(name="{1.name}", mbid="{1.mbid}")'
-        return fmt.format(self.__class__.__name__, self)
-
-    def __str__(self):
-        return str(self.name)
-
-    def __hash__(self):
-        if self.mbid is not None:
-            return hash(self.mbid)
-        else:
-            return id(self)
-
-
-class Album(Meta):
-    __hash__ = Meta.__hash__
-
-    def __init__(self, **kwargs):
-        super().__init__(**kwargs)
-
-    def __eq__(self, other):
-        """
-        Perform mbid equality test if present,
-        else fallback on self.name equality
-        """
-        if hasattr(other, 'mbid'):
-            if other.mbid and self.mbid:
-                return self.mbid == other.mbid
-        return str(self) == str(other)
-
-    @property
-    def album(self):
-        return self.name
-
-# vim: ai ts=4 sw=4 sts=4 expandtab
index 6fb6a0e60a3a86f14c2a180bb24e6043e7cf2127..d589051e3d0461aff175cb0841319fe61eb2672c 100644 (file)
@@ -36,6 +36,33 @@ class Meta:
                 return self.mbid == other.mbid
         return SimaStr(str(self)) == SimaStr(str(other))
 
+    def __hash__(self):
+        if self.mbid is not None:
+            return hash(self.mbid)
+        else:
+            return id(self)
+
+
+class Album(Meta):
+    __hash__ = Meta.__hash__
+
+    def __init__(self, **kwargs):
+        super().__init__(**kwargs)
+
+    def __eq__(self, other):
+        """
+        Perform mbid equality test if present,
+        else fallback on self.name equality
+        """
+        if hasattr(other, 'mbid'):
+            if other.mbid and self.mbid:
+                return self.mbid == other.mbid
+        return str(self) == str(other)
+
+    @property
+    def album(self):
+        return self.name
+
 
 class Artist(Meta):