Cleanup Locale system, remove legacy Locale API, add command help handling, misc

This commit is contained in:
2024-08-07 02:27:17 +02:00
parent 6a1a21027c
commit c9895a4bed
37 changed files with 314 additions and 297 deletions

View File

@ -5,18 +5,29 @@
from types import SimpleNamespace
class SafeNamespace(SimpleNamespace):
def __getattribute__(self, value):
class DictNamespace(SimpleNamespace):
def __iter__(self):
return self.__dict__.__iter__()
def __getitem__(self, key):
return self.__getattribute__(key)
def __setitem__(self, key, value):
return self.__setattr__(key, value)
class SafeNamespace(DictNamespace):
def __getattribute__(self, key):
try:
return super().__getattribute__(value)
return super().__getattribute__(key)
except AttributeError:
return None
# we just use these for type hinting:
# we just use these for type hinting and clearer code:
class EventContext(SafeNamespace):
pass
class UserData(SafeNamespace):
pass
class MessageData(SafeNamespace):
pass