Added else statements

This commit is contained in:
justinta89 2016-01-15 10:48:22 -07:00
parent fac6c3f6ae
commit c20f9b6a87

View File

@ -434,26 +434,28 @@ def check(set=None, entry=None, family='ipv4'):
ipaddress.ip_address(start), ipaddress.ip_address(start),
ipaddress.ip_address(end) + 1 ipaddress.ip_address(end) + 1
)] )]
entries = [' '.join([str(ipaddress.ip_address(ip))]) for ip in range( else:
ipaddress.ip_address(start), entries = [' '.join([str(ipaddress.ip_address(ip))]) for ip in range(
ipaddress.ip_address(end) + 1 ipaddress.ip_address(start),
)] ipaddress.ip_address(end) + 1
)]
elif settype == 'hash:net': elif settype == 'hash:net':
networks = ipaddress.summarize_address_range(ipaddress.ip_address(start), networks = ipaddress.summarize_address_range(ipaddress.ip_address(start),
ipaddress.ip_address(end)) ipaddress.ip_address(end))
entries = [] entries = []
for network in networks: for network in networks:
entries.append(network.with_prefixlen)
_network = [str(ip) for ip in ipaddress.ip_network(network)] _network = [str(ip) for ip in ipaddress.ip_network(network)]
if len(_network) == 1: if len(_network) == 1:
if _entry_extra: if _entry_extra:
__network = ' '.join([str(_network[0]), ' '.join(_entry_extra)]) __network = ' '.join([str(_network[0]), ' '.join(_entry_extra)])
__network = ' '.join([str(_network[0])]) else:
__network = ' '.join([str(_network[0])])
else: else:
if _entry_extra: if _entry_extra:
__network = ' '.join([str(network), ' '.join(_entry_extra)]) __network = ' '.join([str(network), ' '.join(_entry_extra)])
__network = ' '.join([str(network)]) else:
__network = ' '.join([str(network)])
entries.append(__network) entries.append(__network)
else: else:
entries = [entry] entries = [entry]
@ -462,13 +464,15 @@ def check(set=None, entry=None, family='ipv4'):
if settype == 'hash:ip': if settype == 'hash:ip':
if _entry_extra: if _entry_extra:
entries = [' '.join([str(ip), ' '.join(_entry_extra)]) for ip in ipaddress.ip_network(_entry)] entries = [' '.join([str(ip), ' '.join(_entry_extra)]) for ip in ipaddress.ip_network(_entry)]
entries = [' '.join([str(ip)]) for ip in ipaddress.ip_network(_entry)] else:
entries = [' '.join([str(ip)]) for ip in ipaddress.ip_network(_entry)]
elif settype == 'hash:net': elif settype == 'hash:net':
_entries = [str(ip) for ip in ipaddress.ip_network(_entry)] _entries = [str(ip) for ip in ipaddress.ip_network(_entry)]
if len(_entries) == 1: if len(_entries) == 1:
if _entry_extra: if _entry_extra:
entries = [' '.join([_entries[0], ' '.join(_entry_extra)])] entries = [' '.join([_entries[0], ' '.join(_entry_extra)])]
entries = [' '.join([_entries[0]])] else:
entries = [' '.join([_entries[0]])]
else: else:
entries = [entry] entries = [entry]
else: else: