Skip to content

Commit

Permalink
Remove deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Dec 1, 2023
1 parent 7293412 commit e9b0135
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions ciscoconfparse/ccp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,80 +1088,6 @@ def __init__(self, v4input=None, strict=False, debug=0): # nosec
f"Could not parse '{v4input}' {type(v4input)} into an IPv4 Address"
)

#################################### NEW
# do NOT wrap with @logger.catch(...)
# On IPv4Obj()
def _ipv4_params_dict_DEPERCATED(self, arg, debug=0):
"""
Parse out important IPv4 parameters from arg. This method must run to
completion for IPv4 address parsing to work correctly.
"""
if not isinstance(arg, (str, int, IPv4Obj)):
raise ValueError

if isinstance(arg, str):
try:
mm = _RGX_IPV4ADDR_WITH_MASK.search(arg)
except TypeError:
raise AddressValueError(
f"_ipv4_params_dict() doesn't understand how to parse {arg}"
)
except BaseException:
raise AddressValueError(
f"_ipv4_params_dict() doesn't understand how to parse {arg}"
)

error_msg = f"_ipv4_params_dict() couldn't parse '{arg}'"
if mm is None:
raise RequirementFailure(error_msg)

mm_result = mm.groupdict()
addr = (
mm_result["v4addr_nomask"] or mm_result["v4addr_netmask"] or mm_result["v4addr_prefixlen"]
)
# Normalize if we get zero-padded strings, i.e. 172.001.001.001
if not re.search(r"^\d+\.\d+.\d+\.\d+", addr):
raise RequirementFailure()
addr = ".".join([str(int(ii)) for ii in addr.split(".")])

netmask = mm_result["netmask"]

masklen = int(mm_result.get("masklen", None) or IPV4_MAX_PREFIXLEN)

if netmask is not None:
ip_arg_str = f"{addr}/{netmask}"
elif masklen is not None:
ip_arg_str = f"{addr}/{masklen}"
else:
raise AddressValueError()

elif isinstance(arg, int):
addr = str(IPv4Address(arg))
netmask = "255.255.255.255"
masklen = 32
ip_arg_str = f"{addr}/{masklen}"

elif isinstance(arg, IPv4Obj):
addr = str(arg.ip)
netmask = str(arg.netmask)
masklen = arg.masklen
ip_arg_str = f"{addr}/{masklen}"

else:
raise AddressValueError("IPv4Obj(arg='%s') is an unknown argument type" % (arg))

if not (0 <= masklen <= IPV4_MAX_PREFIXLEN):
raise RequirementFailure()
params_dict = {
'ipv4_addr': addr,
'ip_version': 4,
'ip_arg_str': ip_arg_str,
'netmask': netmask,
'masklen': masklen,
}

return params_dict

# do NOT wrap with @logger.catch(...)
# On IPv4Obj()
def __repr__(self):
Expand Down

0 comments on commit e9b0135

Please sign in to comment.