def _convert(ip, notation, inotation, _check, _isnm):
inotation_orig = inotation<EOL>notation_orig = notation<EOL>inotation = _get_notation(inotation)<EOL>notation = _get_notation(notation)<EOL>if inotation is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % inotation_orig)<EOL><DEDENT>if notation is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % notation_orig)<EOL><DEDENT>docheck = _check or False<EOL>if inotation == IP_UNKNOWN:<EOL><INDENT>inotation = _detect(ip, _isnm)<EOL>if inotation == IP_UNKNOWN:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if _check is None:<EOL><INDENT>docheck = True<EOL><DEDENT><DEDENT>if _isnm:<EOL><INDENT>docheck = False<EOL><DEDENT>dec = <NUM_LIT:0><EOL>if inotation == IP_DOT:<EOL><INDENT>dec = _dot_to_dec(ip, docheck)<EOL><DEDENT>elif inotation == IP_HEX:<EOL><INDENT>dec = _hex_to_dec(ip, docheck)<EOL><DEDENT>elif inotation == IP_BIN:<EOL><INDENT>dec = _bin_to_dec(ip, docheck)<EOL><DEDENT>elif inotation == IP_OCT:<EOL><INDENT>dec = _oct_to_dec(ip, docheck)<EOL><DEDENT>elif inotation == IP_DEC:<EOL><INDENT>dec = _dec_to_dec_long(ip, docheck)<EOL><DEDENT>elif _isnm and inotation == NM_BITS:<EOL><INDENT>dec = _bits_to_dec(ip, docheck)<EOL><DEDENT>elif _isnm and inotation == NM_WILDCARD:<EOL><INDENT>dec = _wildcard_to_dec(ip, docheck)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % inotation_orig)<EOL><DEDENT>if _isnm and dec not in _NETMASKS_VALUES:<EOL><INDENT>raise ValueError('<STR_LIT>' % ip)<EOL><DEDENT>if notation == IP_DOT:<EOL><INDENT>return _dec_to_dot(dec)<EOL><DEDENT>elif notation == IP_HEX:<EOL><INDENT>return _dec_to_hex(dec)<EOL><DEDENT>elif notation == IP_BIN:<EOL><INDENT>return _dec_to_bin(dec)<EOL><DEDENT>elif notation == IP_OCT:<EOL><INDENT>return _dec_to_oct(dec)<EOL><DEDENT>elif notation == IP_DEC:<EOL><INDENT>return _dec_to_dec_str(dec)<EOL><DEDENT>elif _isnm and notation == NM_BITS:<EOL><INDENT>return _dec_to_bits(dec)<EOL><DEDENT>elif _isnm and notation == NM_WILDCARD:<EOL><INDENT>return _dec_to_wildcard(dec)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % notation_orig)<EOL><DEDENT>
Internally used to convert IPs and netmasks to other notations.