(string_network)
return True
Very simple check of the cidr format in no_proxy variable
Very simple check of the cidr format in no_proxy variable
Very simple check of the cidr format in no_proxy variable
def is_valid_cidr(string_network):
    """Very simple check of the cidr format in no_proxy variable"""
    if string_network.count('/') == 1:
        try:
            mask = int(string_network.split('/')[1])
        except ValueError:
            return False

        if mask < 1 or mask > 32:
            return False

        try:
            socket.inet_aton(string_network.split('/')[0])
        except socket.error:
            return False
    else:
        return False
    return True
def is_valid_cidr ( string_network ) : if string_network . count ( '/' ) == 1 : try : mask = int ( string_network . split ( '/' ) [ 1 ] ) except ValueError : return False if mask < 1 or mask > 32 : return False try : socket . inet_aton ( string_network . split ( '/' ) [ 0 ] ) except socket . error : return False else : return False return True