matrix_to_string: header columns width
PATCH 1/1 matrix_to_string: header columns width
Hi,
this patch calculates the columns' width including the header's one. In addition it accepts the header of booth types - tuple or list.
Regards,
Lukas
PATCH 1/1 FIX matrix_to_string: header columns width ADD matrix_to_string: accept header of type tupple or list
Signed-off-by Lukas Doktor <[email protected]>
--- client/common_lib/utils.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
client/common_lib/utils.py +6 -1
@@ -211,9 +211,14 @@ def matrix_to_string(matrix, header=None): in each column, and determining the format string dynamically. @param matrix: Matrix representation (list with n rows of m elements). - @param header: Optional tuple with header elements to be displayed. + @param header: Optional tuple or list with header elements to be displayed. """ + if type(header) is list: + header = tuple(header) lengths = [] + if header: + for column in header: + lengths.append(len(column)) for row in matrix: for column in row: i = row.index(column)
Signature · 1 line
1.7.2.3
Re: [PATCH] FIX matrix_to_string: header columns width ADD matrix_to_string: accept header of type tupple or list
Quoted 1 line · Lukas Doktor
Signed-off-by Lukas Doktor <[email protected]>
Ooops, my bad, I forgot about the header. Looks good to me, applied, thanks!
http://autotest.kernel.org/changeset/4818
Lucas
Quoted 24 lines
--- client/common_lib/utils.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)client/common_lib/utils.py +6
-1@@ -211,9 +211,14 @@ def matrix_to_string(matrix, header=None): in each column, and determining the format string dynamically. @param matrix: Matrix representation (list with n rows of m elements). - @param header: Optional tuple with header elements to be displayed. + @param header: Optional tuple or list with header elements to be displayed. """ + if type(header) is list: + header = tuple(header) lengths = [] + if header: + for column in header: + lengths.append(len(column)) for row in matrix: for column in row: i = row.index(column)