#NEWLINE# def print_aligned( self , arr ) : #NEWLINE# #INDENT# if ( len ( arr ) == 0 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# titles = [ 'Option' , 'Description' , 'Current Value' , '' ] #NEWLINE# longest_name = len ( titles [ 0 ] ) #NEWLINE# longest_descr = len ( titles [ 1 ] ) #NEWLINE# longest_value = len ( titles [ 2 ] ) #NEWLINE# longest_possible_value = len ( titles [ 3 ] ) #NEWLINE# for x in arr : #NEWLINE# #INDENT# longest_name = max ( longest_name , len ( x [ 0 ] ) ) #NEWLINE# longest_descr = max ( longest_descr , len ( x [ 1 ] ) ) #NEWLINE# longest_value = max ( longest_value , len ( str ( x [ 2 ] ) ) ) #NEWLINE# if x [ 3 ] : #NEWLINE# #INDENT# longest_possible_value = max ( longest_possible_value , len ( x [ 3 ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( longest_possible_value > 0 ) : #NEWLINE# #INDENT# titles [ 3 ] = 'Possible Values' #NEWLINE# #UNINDENT# print ( ( '  %s%s %s%s %s%s %s' % ( titles [ 0 ] , ( ' ' * ( longest_name - len ( titles [ 0 ] ) ) ) , titles [ 1 ] , ( ' ' * ( longest_descr - len ( titles [ 1 ] ) ) ) , titles [ 2 ] , ( ' ' * ( longest_value - len ( titles [ 2 ] ) ) ) , titles [ 3 ] ) ) ) #NEWLINE# print ( ( '  %s%s %s%s %s%s %s' % ( ( '-' * len ( titles [ 0 ] ) ) , ( ' ' * ( longest_name - len ( titles [ 0 ] ) ) ) , ( '-' * len ( titles [ 1 ] ) ) , ( ' ' * ( longest_descr - len ( titles [ 1 ] ) ) ) , ( '-' * len ( titles [ 2 ] ) ) , ( ' ' * ( longest_value - len ( titles [ 2 ] ) ) ) , ( '-' * len ( titles [ 3 ] ) ) ) ) ) #NEWLINE# for i in arr : #NEWLINE# #INDENT# name = i [ 0 ] #NEWLINE# descr = i [ 1 ] #NEWLINE# value = ( i [ 2 ] if isinstance ( i [ 2 ] , str ) else str ( i [ 2 ] ) . lower ( ) ) #NEWLINE# possible_values = '' #NEWLINE# if isinstance ( i [ 3 ] , list ) : #NEWLINE# #INDENT# if ( len ( i [ 3 ] ) > 0 ) : #NEWLINE# #INDENT# i [ 3 ] = [ ( s if isinstance ( s , str ) else str ( s ) . lower ( ) ) for s in i [ 3 ] ] #NEWLINE# possible_values = ( '[%s]' % ', ' . join ( map ( str , i [ 3 ] ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if i [ 3 ] : #NEWLINE# #INDENT# possible_values = ( i [ 3 ] if isinstance ( i [ 3 ] , str ) else str ( i [ 3 ] ) . lower ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# namepad = ( ' ' * ( longest_name - len ( name ) ) ) #NEWLINE# descrpad = ( ' ' * ( longest_descr - len ( descr ) ) ) #NEWLINE# valuepad = ( ' ' * ( longest_value - len ( str ( value ) ) ) ) #NEWLINE# f = ( '  %s%s %s%s %s%s %s' % ( name , namepad , descr , descrpad , value , valuepad , possible_values ) ) #NEWLINE# print ( f )