Add method to convert a ThreadType to a subclass of Thread (e.g. Group)

This commit is contained in:
Mads Marquart
2019-08-28 17:39:49 +02:00
parent 0838f84859
commit 5e86d4a48a

View File

@@ -16,6 +16,17 @@ class ThreadType(Enum):
ROOM = 2 ROOM = 2
PAGE = 3 PAGE = 3
def _to_class(self):
"""Convert this enum value to the corresponding class."""
from . import _user, _group, _page
return {
ThreadType.USER: _user.User,
ThreadType.GROUP: _group.Group,
ThreadType.ROOM: _group.Room,
ThreadType.PAGE: _page.Page,
}[self]
class ThreadLocation(Enum): class ThreadLocation(Enum):
"""Used to specify where a thread is located (inbox, pending, archived, other).""" """Used to specify where a thread is located (inbox, pending, archived, other)."""