utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:needybot-core 作者: needybot 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号