Move to f-strings
Used: $ flynt -a -tc . vppcfg Execution time: 0.216s Files checked: 24 Files modified: 13 Character count reduction: 632 (0.36%) Per expression type: Old style (`%`) expressions attempted: 209/211 (99.1%) No `.format(...)` calls attempted. No concatenations attempted. F-string expressions created: 205 Ran an integration test before and after. No diffs.
This commit is contained in:
@ -62,40 +62,40 @@ def validate_taps(yaml):
|
||||
return result, msgs
|
||||
|
||||
for ifname, iface in yaml['taps'].items():
|
||||
logger.debug("tap %s" % iface)
|
||||
logger.debug(f"tap {iface}")
|
||||
instance = int(ifname[3:])
|
||||
|
||||
## NOTE(pim): 1024 is not off-by-one, tap1024 is precisely the highest permissible id
|
||||
if instance > 1024:
|
||||
msgs.append("tap %s has instance %d which is too large" % (ifname, instance))
|
||||
msgs.append(f"tap {ifname} has instance {int(instance)} which is too large")
|
||||
result = False
|
||||
|
||||
if not is_host_name_unique(yaml, iface['host']['name']):
|
||||
msgs.append("tap %s does not have a unique host name %s" % (ifname, iface['host']['name']))
|
||||
msgs.append(f"tap {ifname} does not have a unique host name {iface['host']['name']}")
|
||||
result = False
|
||||
|
||||
if 'rx-ring-size' in iface:
|
||||
n = iface['rx-ring-size']
|
||||
if n & (n-1) != 0:
|
||||
msgs.append("tap %s rx-ring-size must be a power of two" % (ifname))
|
||||
msgs.append(f"tap {ifname} rx-ring-size must be a power of two")
|
||||
result = False
|
||||
|
||||
if 'tx-ring-size' in iface:
|
||||
n = iface['tx-ring-size']
|
||||
if n & (n-1) != 0:
|
||||
msgs.append("tap %s tx-ring-size must be a power of two" % (ifname))
|
||||
msgs.append(f"tap {ifname} tx-ring-size must be a power of two")
|
||||
result = False
|
||||
|
||||
if 'namespace-create' in iface['host'] and iface['host']['namespace-create'] and not 'namespace' in iface['host']:
|
||||
msgs.append("tap %s namespace-create can only be set if namespace is set" % (ifname))
|
||||
msgs.append(f"tap {ifname} namespace-create can only be set if namespace is set")
|
||||
result = False
|
||||
|
||||
if 'bridge-create' in iface['host'] and iface['host']['bridge-create'] and not 'bridge' in iface['host']:
|
||||
msgs.append("tap %s bridge-create can only be set if bridge is set" % (ifname))
|
||||
msgs.append(f"tap {ifname} bridge-create can only be set if bridge is set")
|
||||
result = False
|
||||
|
||||
if 'mac' in iface['host'] and mac.is_multicast(iface['host']['mac']):
|
||||
msgs.append("tap %s host MAC address %s cannot be multicast" % (ifname, iface['host']['mac']))
|
||||
msgs.append(f"tap {ifname} host MAC address {iface['host']['mac']} cannot be multicast")
|
||||
result = False
|
||||
|
||||
return result, msgs
|
||||
|
Reference in New Issue
Block a user