def resolve_topic_name(topic):
"""
Given a topic of type `enum.Enum`, or of type `str`,
get the string value of its publisher channel.
Args:
topic (enum.Enum | str): the topic to resolve, as
either an enum.Enum type or a string.
Returns:
string: the publisher channel for the topic
None: if the topic arg is not one of the two acceptable
types, then None is returned
"""
if isinstance(topic, enum.Enum):
return topic.value
elif isinstance(topic, str):
return topic
else:
return None
评论列表
文章目录