X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=ac5948ab82e1a5aef1cdf247578ee84dca3e2133;hb=HEAD;hp=9e858a2bc972ffc1ef557bc27c41beb6f37cbf60;hpb=d1af78455dfab9e371770228191e28ed8386bd2f;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 9e858a2..ac5948a 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -26,11 +26,15 @@ from collections.abc import Set import logging import re +from ..utils.utils import MPDSimaException + + UUID_RE = r'^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[89AB][a-f0-9]{3}-[a-f0-9]{12}$' #: The Track Object is collapsing multiple tags into a single string using this # separator. It is used then to split back the string to tags list. SEPARATOR = chr(0x1F) # ASCII Unit Separator + def is_uuid4(uuid): """Controls MusicBrainz UUID4 format @@ -42,7 +46,8 @@ def is_uuid4(uuid): return True return False -class MetaException(Exception): + +class MetaException(MPDSimaException): """Generic Meta Exception""" @@ -92,8 +97,7 @@ class Meta: raise MetaException('Need a "name" argument (str type)') if not isinstance(kwargs.get('name'), str): raise MetaException('"name" argument not a string') - else: - self.__name = kwargs.pop('name').split(SEPARATOR)[0] + self.__name = kwargs.pop('name').split(SEPARATOR)[0] if 'mbid' in kwargs and kwargs.get('mbid'): mbid = kwargs.get('mbid').lower().split(SEPARATOR)[0] if is_uuid4(mbid): @@ -143,7 +147,7 @@ class Meta: if callable(other.__str__) and other.__str__() != self.name: self.__aliases |= {other.__str__()} else: - raise MetaException('No __str__ method found in {!r}'.format(other)) + raise MetaException(f'No __str__ method found in {other!r}') @property def name(self): @@ -170,7 +174,7 @@ class Meta: @property def names(self): """aliases + name""" - return self.__aliases | {self.__name,} + return self.__aliases | {self.__name, } @property @serialize