]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/meta.py
New option to disable use of mbid
[mpd-sima.git] / sima / lib / meta.py
index 32bb883dca5dd861a0b1f21b9fec89055edfc3c7..2d78f2f67269cfedfb2898a2aa3f3e1e025bc21d 100644 (file)
@@ -38,11 +38,22 @@ class MetaException(Exception):
 class WrongUUID4(MetaException):
     pass
 
+def mbidfilter(func):
+    def wrapper(*args, **kwargs):
+        cls = args[0]
+        if not cls.use_mbid:
+            kwargs.pop('mbid', None)
+            kwargs.pop('musicbrainz_artistid', None)
+            kwargs.pop('musicbrainz_albumartistid', None)
+        func(*args, **kwargs)
+    return wrapper
+
 
 class Meta:
     """Generic Class for Meta object
     Meta(name=<str>[, mbid=UUID4])
     """
+    use_mbid = True
 
     def __init__(self, **kwargs):
         self.__name = None #TODO: should be immutable
@@ -117,6 +128,7 @@ class Album(Meta):
 
 class Artist(Meta):
 
+    @mbidfilter
     def __init__(self, name=None, mbid=None, **kwargs):
         """Artist object built from a mapping dict containing at least an
         "artist" entry: