mirror of
https://gitlab.com/octospacc/WinDog.git
synced 2025-06-05 22:09:20 +02:00
Cleanup Locale system, remove legacy Locale API, add command help handling, misc
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user