__init__.py 文件源码

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

项目:l3overlay 作者: catalyst 项目源码 文件源码
def ip_address_get(value):
    '''
    Get an IP address from a string. Raises a GetError if the string
    is not a valid IP address. Supports both IPv4 and IPv6.
    '''

    if isinstance(value, (ipaddress.IPv4Network, ipaddress.IPv6Network)):
        raise GetError(
            "%s not allowed to be converted to IP address, use class attributes" %
            type(value).__name__,
        )

    try:
        return ipaddress.ip_address(value)
    except ValueError:
        raise GetError("value '%s' is not a valid IPv4/IPv6 address" % value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号