X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=af3e19c14e781622480de208954d1952f745ac08;hb=e86c25ed9e97c5dd3e0672d5b17bed01d4a23fdf;hp=e6b9f46229554e008422017281de51db7d9be680;hpb=28caa80fbddaca9c7bb83a9d72dfba8130f16e44;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index e6b9f46..af3e19c 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""" @@ -61,8 +66,8 @@ def serialize(func): def wrapper(*args, **kwargs): ans = func(*args, **kwargs) if isinstance(ans, set): - return {s.replace("'", r"\'") for s in ans} - return ans.replace("'", r"\'") + return {s.replace("'", r"\'").replace('"', r'\"') for s in ans} + return ans.replace("'", r"\'").replace('"', r'\"') return wrapper @@ -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): @@ -170,7 +174,7 @@ class Meta: @property def names(self): """aliases + name""" - return self.__aliases | {self.__name,} + return self.__aliases | {self.__name, } @property @serialize