Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cleanup(addresses, complement_addresses):
if not optimize:
return nacaddr.SortAddrList(addresses)
if addressbook:
return nacaddr.CollapseAddrListPreserveTokens(addresses)
else:
return nacaddr.CollapseAddrList(addresses, complement_addresses)
def Summarize(nets):
"""Summarizes networks while allowing for discontinuous subnet mask.
Args:
nets: list of nacaddr.IPv4 or nacaddr.IPv6 objects.
Address family can be mixed, however there is no support for rendering
anything other than IPv4.
Returns:
sorted list of DSMIPNet objects.
"""
result = []
optimized_nets = nacaddr.CollapseAddrList(nets)
nets_by_netmask = collections.defaultdict(list)
# group nets by subnet mask
for net in optimized_nets:
nets_by_netmask[net.prefixlen].append(_NacaddrNetToDSMNet(net))
for nets in nets_by_netmask.values():
result.extend(_SummarizeSameMask(nets))
return sorted(result)
def cleanup(addresses, complement_addresses):
if not optimize:
return nacaddr.SortAddrList(addresses)
if addressbook:
return nacaddr.CollapseAddrListPreserveTokens(addresses)
else:
return nacaddr.CollapseAddrList(addresses, complement_addresses)