nettest.py 文件源码

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

项目:nettool 作者: heyglen 项目源码 文件源码
def network(cls, value, raise_exception=False):
            """ Network address validation """
            if not isinstance(value, basestring):
                if raise_exception:
                    raise TypeError('Invalid type \'{}\''.format(type(value)))
                return False
            terms = value.split()
            if len(terms) is 2:
                if cls.ip(terms[0]):
                    if cls.netmask(terms[1]):
                        terms[1] = NetTest.convert.netmask.prefix(terms[1])
                    elif cls.wildcard(terms[1]):
                        terms[1] = NetTest.convert.wildcard.prefix(terms[1])
                    terms[1] = unicode(terms[1])
                value = u'/'.join(terms)
            try:
                value = unicode(value)
                ipaddress.IPv4Interface(value)
            except (ValueError, TypeError):
                if raise_exception:
                    raise
                return False
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号