Prettifiy formatting of columns

This commit is contained in:
Joshua Boniface 2018-06-07 00:21:15 -04:00
parent 7309af5ec0
commit 8ce24d9660
1 changed files with 9 additions and 4 deletions

11
pvcf.py
View File

@ -151,9 +151,14 @@ def getInformationFromXML(zk, uuid, long_output):
if long_output == True: if long_output == True:
# Disk list # Disk list
ainformation.append('') ainformation.append('')
ainformation.append('{}Disks:{} {}ID Type Name Dev Bus{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end())) name_length = 0
for disk in ddisks: for disk in ddisks:
ainformation.append(' {0: <3} {1: <5} {2: <42} {3: <4} {4: <5}'.format(ddisks.index(disk), disk['type'], disk['name'], disk['dev'], disk['bus'])) _name_length = len(disk['name']) + 1
if _name_length > name_length:
name_length = _name_length
ainformation.append('{0}Disks:{1} {2}ID Type {3: <{width}} Dev Bus{4}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), 'Name', ansiiprint.end(), width=name_length))
for disk in ddisks:
ainformation.append(' {0: <3} {1: <5} {2: <{width}} {3: <4} {4: <5}'.format(ddisks.index(disk), disk['type'], disk['name'], disk['dev'], disk['bus'], width=name_length))
# Network list # Network list
ainformation.append('') ainformation.append('')
ainformation.append('{}Interfaces:{} {}ID Type Source Model MAC{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end())) ainformation.append('{}Interfaces:{} {}ID Type Source Model MAC{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end()))
@ -163,7 +168,7 @@ def getInformationFromXML(zk, uuid, long_output):
ainformation.append('') ainformation.append('')
ainformation.append('{}Controllers:{} {}ID Type Model{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end())) ainformation.append('{}Controllers:{} {}ID Type Model{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end()))
for controller in dcontrollers: for controller in dcontrollers:
ainformation.append(' {0: <3} {1: <8} {2: <8}'.format(dcontrollers.index(controller), controller['type'], controller['model'])) ainformation.append(' {0: <3} {1: <14} {2: <8}'.format(dcontrollers.index(controller), controller['type'], controller['model']))
# Join it all together # Join it all together
information = '\n'.join(ainformation) information = '\n'.join(ainformation)