1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-07-30 01:23:26 +02:00

Added __eq__ to MlString

Now an MlString instance is able to say if another MlString instance is equivalent using mlstr1 == mlstr2
This commit is contained in:
Yann 2015-06-18 13:40:06 +02:00
commit 712a2710a0

View file

@ -27,6 +27,16 @@ class MlString(object):
else: else:
return "" return ""
def __eq__(self, other):
if not isinstance(other, MlString):
return False
if not set(lng for lng in self.translations) == set( lng for lng in other.translations):
return False
for lng in self.translations:
if self.get(lng) != other.get(lng):
return False
return True
@staticmethod @staticmethod
def load(json_string): def load(json_string):
if isinstance(json_string, str) and json_string != '': if isinstance(json_string, str) and json_string != '':