simplify netmaskoption

This commit is contained in:
Emmanuel Garette 2019-02-25 19:29:00 +01:00
parent 74d367c731
commit a248e114de

View file

@ -84,7 +84,7 @@ class NetmaskOption(StrOption):
val_netmask, val_ip = vals val_netmask, val_ip = vals
opt_netmask, opt_ip = opts opt_netmask, opt_ip = opts
ip = ip_interface('{0}/{1}'.format(val_ip, val_netmask)) ip = ip_interface('{0}/{1}'.format(val_ip, val_netmask))
if not _cidr and current_opt == opt_ip if not _cidr and current_opt == opt_ip:
if ip.ip == ip.network.network_address: if ip.ip == ip.network.network_address:
raise ValueError( _('this is a network with netmask "{0}" ("{1}")' raise ValueError( _('this is a network with netmask "{0}" ("{1}")'
'').format(val_netmask, '').format(val_netmask,
@ -100,5 +100,5 @@ class NetmaskOption(StrOption):
opt_ip.impl_get_display_name())) opt_ip.impl_get_display_name()))
elif ip.ip == ip.network.broadcast_address: elif ip.ip == ip.network.broadcast_address:
raise ValueError(_('IP "{0}" ("{1}") is the broadcast' raise ValueError(_('IP "{0}" ("{1}") is the broadcast'
'')format(val_ip, '').format(val_ip,
opt_ip.impl_get_display_name())) opt_ip.impl_get_display_name()))