X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=f118e82dcfd19c7dce1b3d426ff2c6dd0c08485c;hb=37dd60538984a3917354b794a5c96b0a025f8e95;hp=725bfb00afde57b80d4caf39acb9e1968ca394ab;hpb=c7bfe1ff39adb2eed8d946abbba59f8f9748ca9b;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 725bfb0..f118e82 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -31,6 +31,7 @@ UUID_RE = r'^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[89AB][a-f0-9]{3}-[a-f0-9]{12}$ # 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,6 +43,7 @@ def is_uuid4(uuid): return True return False + class MetaException(Exception): """Generic Meta Exception""" @@ -61,8 +63,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 @@ -136,12 +138,12 @@ class Meta: :param str other: Alias to add, could be any object with ``__str__`` method. """ + if isinstance(other, Meta): + self.__aliases |= other.__aliases + self.__aliases -= {self.name} if getattr(other, '__str__', None): if callable(other.__str__) and other.__str__() != self.name: self.__aliases |= {other.__str__()} - elif isinstance(other, Meta): - if other.name != self.name: - self.__aliases |= other.__aliases else: raise MetaException('No __str__ method found in {!r}'.format(other)) @@ -170,7 +172,7 @@ class Meta: @property def names(self): """aliases + name""" - return self.__aliases | {self.__name,} + return self.__aliases | {self.__name, } @property @serialize