コード例 #1
0
def valid_str(addr):
    """
    @param addr: An IPv6 address in presentation (string) format.

    @return: C{True} if IPv6 address is valid, C{False} otherwise.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')

    try:
        _inet_pton(AF_INET6, addr)
    except:
        return False
    return True
コード例 #2
0
ファイル: ipv6.py プロジェクト: a0726h77/ipscan
def valid_str(addr):
    """
    @param addr: An IPv6 address in presentation (string) format.

    @return: C{True} if IPv6 address is valid, C{False} otherwise.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')

    try:
        _inet_pton(AF_INET6, addr)
    except:
        return False
    return True
コード例 #3
0
def valid_str(addr, flags=0):
    """
    :param addr: An IPv6 address in presentation (string) format.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: ``True`` if IPv6 address is valid, ``False`` otherwise.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')

    try:
        _inet_pton(AF_INET6, addr)
    except:
        return False
    return True
コード例 #4
0
ファイル: ipv6.py プロジェクト: Metaswitch/netaddr
def valid_str(addr, flags=0):
    """
    :param addr: An IPv6 address in presentation (string) format.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: ``True`` if IPv6 address is valid, ``False`` otherwise.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')

    try:
        _inet_pton(AF_INET6, addr)
    except:
        return False
    return True
コード例 #5
0
def str_to_int(addr, flags=0):
    """
    :param addr: An IPv6 address in string form.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: The equivalent unsigned integer for a given IPv6 address.
    """
    try:
        packed_int = _inet_pton(AF_INET6, addr)
        return packed_to_int(packed_int)
    except Exception:
        raise AddrFormatError('%r is not a valid IPv6 address string!' % addr)
コード例 #6
0
ファイル: ipv6.py プロジェクト: Metaswitch/netaddr
def str_to_int(addr, flags=0):
    """
    :param addr: An IPv6 address in string form.

    :param flags: decides which rules are applied to the interpretation of the
        addr value. Future use - currently has no effect.

    :return: The equivalent unsigned integer for a given IPv6 address.
    """
    try:
        packed_int = _inet_pton(AF_INET6, addr)
        return packed_to_int(packed_int)
    except Exception:
        raise AddrFormatError('%r is not a valid IPv6 address string!' % addr)
コード例 #7
0
def str_to_int(addr):
    """
    @param addr: An IPv6 address in string form.

    @return: The equivalent unsigned integer for a given IPv6 address.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')
    try:
        packed_int = _inet_pton(AF_INET6, addr)
        return packed_to_int(packed_int)
    except Exception:
        raise AddrFormatError('%r is not a valid IPv6 address string!' \
            % addr)
コード例 #8
0
ファイル: ipv6.py プロジェクト: a0726h77/ipscan
def str_to_int(addr):
    """
    @param addr: An IPv6 address in string form.

    @return: The equivalent unsigned integer for a given IPv6 address.
    """
    if addr == '':
        raise AddrFormatError('Empty strings are not supported!')
    try:
        packed_int = _inet_pton(AF_INET6, addr)
        return packed_to_int(packed_int)
    except Exception:
        raise AddrFormatError('%r is not a valid IPv6 address string!' \
            % addr)