__init__.py 文件源码

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

项目:l3overlay 作者: catalyst 项目源码 文件源码
def name_get(value):
    '''
    Check that a string is a valid name, and return it. A name is a string
    that is just one word, without whitespace. Raise a GetError if the
    string is not a valid name.
    '''

    if not isinstance(value, str):
        raise GetError("non-string value '%s' not a valid name" % value)

    if not value:
        raise GetError("empty string not a valid name")

    name = value.strip()

    if not re.fullmatch("[^\\s][^\\s]*", name):
        raise GetError("given string not a valid name (contains whitespace): %s" % name)

    return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号