]> kaliko git repositories - mpd-sima.git/commitdiff
Fixed blacklisting decorator
authorkaliko <efrim@azylum.org>
Mon, 17 Feb 2014 10:18:17 +0000 (11:18 +0100)
committerkaliko <efrim@azylum.org>
Mon, 17 Feb 2014 10:18:17 +0000 (11:18 +0100)
sima/client.py

index 9bee62d0e4397c7173cccce7ec8706526081a01c..c04b259a90a147e4d3545012f8232fcd8ff39270 100644 (file)
@@ -66,16 +66,17 @@ def blacklist(artist=False, album=False, track=False):
             #bl_getter = next(fn for fn, bl in zip(bl_fun, boolgen) if bl is True)
             bl_getter = next(dropwhile(lambda _: not next(boolgen), bl_fun))
             #cls.log.debug('using {0} as bl filter'.format(bl_getter.__name__))
-            results = func(*args, **kwargs)
-            for elem in results:
+            results = list()
+            for elem in func(*args, **kwargs):
                 if bl_getter(elem, add_not=True):
-                    cls.log.info('Blacklisted: {0}'.format(elem))
-                    results.remove(elem)
+                    cls.log.debug('Blacklisted "{0}"'.format(elem))
+                    continue
                 if track and cls.database.get_bl_album(elem, add_not=True):
                     # filter album as well in track mode
                     # (artist have already been)
-                    cls.log.info('Blacklisted: {0}'.format(elem))
-                    results.remove(elem)
+                    cls.log.debug('Blacklisted alb. "{0.album}"'.format(elem))
+                    continue
+                results.append(elem)
             return results
         return wrapper
     return decorated