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:
parent
a9757a4672
commit
712a2710a0
1 changed files with 10 additions and 0 deletions
|
|
@ -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 != '':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue