mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Remove use of try/except for flow control
If the intent is to only extract the 7th column if it exists then it makes more sense to actually test for the number of columns rather than catch an IndexError which may occur at any of the 3 list index operations within the try block.
This commit is contained in:
parent
213c2f64e8
commit
1ad50f7dc6
@ -135,14 +135,12 @@ def list_(device, unit=None):
|
||||
'physical sector': cols[4],
|
||||
'partition table': cols[5],
|
||||
'model': cols[6]}
|
||||
try:
|
||||
if len(cols) == 8:
|
||||
ret['info']['disk flags'] = cols[7]
|
||||
except IndexError:
|
||||
# Older parted (2.x) doesn't show disk flags in the 'print'
|
||||
# output, and will return a 7-column output for the info
|
||||
# line. In these cases we just leave this field out of the
|
||||
# return dict.
|
||||
pass
|
||||
mode = 'partitions'
|
||||
else:
|
||||
ret['partitions'][cols[0]] = {
|
||||
|
Loading…
Reference in New Issue
Block a user