Add method to convert a ThreadType to a subclass of Thread (e.g. Group)
This commit is contained in:
@@ -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)."""
|
||||||
|
Reference in New Issue
Block a user