X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fmeta.py;h=9e858a2bc972ffc1ef557bc27c41beb6f37cbf60;hb=d1af78455dfab9e371770228191e28ed8386bd2f;hp=9d15c69dacef0594f9bdcd7ecd76ac75f04b6c77;hpb=2b41de301271772c0a4667e81e1f2d180f349279;p=mpd-sima.git diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 9d15c69..9e858a2 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -27,7 +27,7 @@ import logging import re 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 +#: 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 @@ -61,8 +61,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 +136,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))