1 # -*- coding: utf-8 -*-
3 from .track import Track
5 class MetaException(Exception):
10 def __init__(self, **kwargs):
13 if 'name' not in kwargs:
14 raise MetaException('need at least a "name" argument')
15 self.__dict__.update(kwargs)
18 fmt = '{0}(name="{1.name}", mbid="{1.mbid}")'
19 return fmt.format(self.__class__.__name__, self)
25 if self.mbid is not None:
26 return hash(self.mbid)
32 __hash__ = Meta.__hash__
34 def __init__(self, **kwargs):
35 super().__init__(**kwargs)
37 def __eq__(self, other):
39 Perform mbid equality test if present,
40 else fallback on self.name equality
42 if hasattr(other, 'mbid'):
43 if other.mbid and self.mbid:
44 return self.mbid == other.mbid
45 return str(self) == str(other)
51 # vim: ai ts=4 sw=4 sts=4 expandtab