X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=949b5562a791385c534babb097f0e1430d256e3a;hb=08d0003d11906338f32a54891edd13fe8316abcd;hp=d589051e3d0461aff175cb0841319fe61eb2672c;hpb=9ec2e9036e1f0fe67e8ddd7e8fb7f91a2e86cd62;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index d589051..949b556 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -1,9 +1,30 @@ # -*- coding: utf-8 -*- +# Copyright (c) 2013, 2014 Jack Kaliko +# +# This file is part of sima +# +# sima is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# sima is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with sima. If not, see . +# +# +""" +Defines some object to handle audio file metadata +""" from .simastr import SimaStr -from .track import Track class MetaException(Exception): + """Generic Meta Exception""" pass class NotSameArtist(MetaException): @@ -11,6 +32,7 @@ class NotSameArtist(MetaException): class Meta: + """Generic Class for Meta object""" def __init__(self, **kwargs): self.name = None @@ -42,6 +64,8 @@ class Meta: else: return id(self) + def __bool__(self): # empty name not possible for a valid obj + return bool(self.name) class Album(Meta): __hash__ = Meta.__hash__ @@ -67,15 +91,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): @@ -86,14 +110,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 -