def get_messages(module):
"""Return a dictionary of message names and objects.
Args:
module (module): A Python module; dir() will be run against this
module to find Message subclasses.
Returns:
dict[str, Message]: A dictionary with the Message class names as
keys, and the Message subclasses themselves as values.
"""
answer = collections.OrderedDict()
for name in dir(module):
candidate = getattr(module, name)
if inspect.isclass(candidate) and issubclass(candidate, Message):
answer[name] = candidate
return answer
评论列表
文章目录