updated select_disk()

This commit is contained in:
Alan Mason 2017-11-30 22:35:16 -08:00
parent 6903078ee0
commit a0460d6a82

View file

@ -330,26 +330,25 @@ def select_disk(title='Which disk?', disks):
disk_options = [] disk_options = []
for disk in disks: for disk in disks:
display_name = '{Size}\t[{Table}] ({Type}) {Name}'.format(**disk) display_name = '{Size}\t[{Table}] ({Type}) {Name}'.format(**disk)
if disk['Partitions']: pwidth=len(str(len(disk['Partitions'])))
pwidth=len(str(len(disk['Partitions']))) for par in disk['Partitions']:
for par in disk['Partitions']: # Main text
# Show unsupported partition(s) in RED p_name = 'Partition {num:>{width}}: {size} ({fs})'.format(
par_skip = False num = par['Number'],
if 'Letter' not in par or re.search(r'(RAW|Unknown)', par['FileSystem'], re.IGNORECASE): width = pwidth,
par_skip = True size = par['Size'],
if par_skip: fs = par['FileSystem'])
display_name += COLORS['YELLOW'] if par['Name']:
p_name += '\t"{}"'.format(par['Name'])
# Show unsupported partition(s)
if 'Letter' not in par or REGEX_BAD_PARTITION.search(par['FileSystem']):
p_display_name = '{YELLOW}{display}{CLEAR}'.format(display=p_name, **COLORS)
display_name += '\n\t\t\t{}'.format(display_name)
if not disk['Partitions']:
display_name += '\n\t\t\t{YELLOW}No partitions found.{CLEAR}'.format(**COLORS)
# Main text
display_name += '\n\t\t\tPartition {Number:>{pwidth}}: {Size} ({FileSystem})'.format(pwidth=pwidth, **par)
if par['Name'] != '':
display_name += '\t"{Name}"'.format(**par)
# Clear color (if set above)
if par_skip:
display_name += COLORS['CLEAR']
else:
display_name += '{YELLOW}\n\t\t\tNo partitions found.{CLEAR}'.format(**COLORS)
disk_options.append({'Name': display_name, 'Disk': disk}) disk_options.append({'Name': display_name, 'Disk': disk})
actions = [ actions = [
{'Name': 'Main Menu', 'Letter': 'M'}, {'Name': 'Main Menu', 'Letter': 'M'},