tools/qvm-features: make pylint happy

reduce number of return statements.
This commit is contained in:
Marek Marczykowski-Górecki 2017-02-13 00:10:18 +01:00
parent a317e81d7e
commit e50b17a6b3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -64,24 +64,19 @@ def main(args=None):
# Request mode: instead of setting the features directly, # Request mode: instead of setting the features directly,
# let the extensions handle them first. # let the extensions handle them first.
vm.fire_event('feature-request', untrusted_features=args.features) vm.fire_event('feature-request', untrusted_features=args.features)
return 0
if args.feature is None: elif args.feature is None:
if args.delete: if args.delete:
parser.error('--unset requires a feature') parser.error('--unset requires a feature')
if not vm.features: # max doesn't like empty list
# max doesn't like empty list if vm.features:
return 0 width = max(len(feature) for feature in vm.features)
for feature in sorted(vm.features):
print('{name:{width}s} {value}'.format(
name=feature, value=vm.features[feature], width=width))
width = max(len(feature) for feature in vm.features) elif args.delete:
for feature in sorted(vm.features):
print('{name:{width}s} {value}'.format(
name=feature, value=vm.features[feature], width=width))
return 0
if args.delete:
if args.value is not None: if args.value is not None:
parser.error('cannot both set and unset a value') parser.error('cannot both set and unset a value')
try: try:
@ -89,17 +84,17 @@ def main(args=None):
args.app.save() args.app.save()
except KeyError: except KeyError:
pass pass
return 0
if args.value is None: elif args.value is None:
try: try:
print(vm.features[args.feature]) print(vm.features[args.feature])
return 0 return 0
except KeyError: except KeyError:
return 1 return 1
else:
vm.features[args.feature] = args.value
args.app.save()
vm.features[args.feature] = args.value
args.app.save()
return 0 return 0