[!] fix2 __getattr__
This commit is contained in:
parent
3581e6ae44
commit
0b9f8b6feb
@ -19,12 +19,17 @@ class NestedAccessor:
|
||||
self.key_chain = key_chain
|
||||
|
||||
def __getattr__(self, item):
|
||||
return NestedAccessor(self.parent, self.key_chain + [item]) # Продолжаем цепочку
|
||||
if item.startswith("__"): # Проверяем системные атрибуты
|
||||
raise AttributeError(f"'{item}' is not accessible")
|
||||
return NestedAccessor(self.parent, self.key_chain + [item])
|
||||
|
||||
def __call__(self, **kwargs):
|
||||
key = ".".join(self.key_chain)
|
||||
return self.parent.get_phrase(key, **kwargs)
|
||||
|
||||
def __add__(self, other):
|
||||
return self() + other
|
||||
|
||||
def __str__(self):
|
||||
return self()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user