summaryrefslogtreecommitdiffhomepage
path: root/libs/subzero
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2020-09-10 14:26:37 -0400
committerGitHub <[email protected]>2020-09-10 14:26:37 -0400
commit5658a7a359a520f4ce4b16f5c909cb45c35572af (patch)
tree4e487067b9f447f3ea1493a64dd8ee9feb0db7ca /libs/subzero
parent35ee6fb6f61dd79b8289b70bef6054708e499b4d (diff)
downloadbazarr-5658a7a359a520f4ce4b16f5c909cb45c35572af.tar.gz
bazarr-5658a7a359a520f4ce4b16f5c909cb45c35572af.zip
Hearing impaired (#1102)
Diffstat (limited to 'libs/subzero')
-rw-r--r--libs/subzero/language.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/libs/subzero/language.py b/libs/subzero/language.py
index 12d41d26e..43dc29754 100644
--- a/libs/subzero/language.py
+++ b/libs/subzero/language.py
@@ -62,6 +62,7 @@ def wrap_forced(f):
args = args[1:]
s = args.pop(0)
forced = None
+ hi = None
if isinstance(s, (str,)):
base, forced = s.split(":") if ":" in s else (s, False)
else:
@@ -70,6 +71,7 @@ def wrap_forced(f):
instance = f(cls, base, *args, **kwargs)
if isinstance(instance, Language):
instance.forced = forced == "forced"
+ instance.hi = hi == "hi"
return instance
return inner
@@ -77,16 +79,18 @@ def wrap_forced(f):
class Language(Language_):
forced = False
+ hi = False
- def __init__(self, language, country=None, script=None, unknown=None, forced=False):
+ def __init__(self, language, country=None, script=None, unknown=None, forced=False, hi=False):
self.forced = forced
+ self.hi = hi
super(Language, self).__init__(language, country=country, script=script, unknown=unknown)
def __getstate__(self):
- return self.alpha3, self.country, self.script, self.forced
+ return self.alpha3, self.country, self.script, self.hi, self.forced
- def __setstate__(self, state):
- self.alpha3, self.country, self.script, self.forced = state
+ def __setstate__(self, forced):
+ self.alpha3, self.country, self.script, self.hi, self.forced = forced
def __hash__(self):
return hash(str(self))
@@ -99,7 +103,8 @@ class Language(Language_):
return (self.alpha3 == other.alpha3 and
self.country == other.country and
self.script == other.script and
- bool(self.forced) == bool(other.forced))
+ bool(self.forced) == bool(other.forced) and
+ bool(self.hi) == bool(other.hi))
def __str__(self):
return super(Language, self).__str__() + (":forced" if self.forced else "")
@@ -112,12 +117,13 @@ class Language(Language_):
ret = super(Language, self).__getattr__(name)
if isinstance(ret, Language):
ret.forced = self.forced
+ ret.hi = self.hi
return ret
@classmethod
def rebuild(cls, instance, **replkw):
state = instance.__getstate__()
- attrs = ("country", "script", "forced")
+ attrs = ("country", "script", "hi", "forced")
language = state[0]
kwa = dict(list(zip(attrs, state[1:])))
kwa.update(replkw)