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:
Dave Rawks 2014-09-23 14:01:21 -07:00 committed by rallytime
parent 213c2f64e8
commit 1ad50f7dc6

View File

@ -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]] = {