From: Luke Kenneth Casson Leighton Date: Mon, 10 Apr 2023 12:55:53 +0000 (+0100) Subject: use dict.get() in column_header_replacement function X-Git-Tag: opf_rfc_ls012_v1~29 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3ec598b87340a0e69586b3319feae76b4e365ed;p=libreriscv.git use dict.get() in column_header_replacement function --- diff --git a/openpower/sv/rfc/ls012_optable.py b/openpower/sv/rfc/ls012_optable.py index 4aeb831e0..592b83b90 100644 --- a/openpower/sv/rfc/ls012_optable.py +++ b/openpower/sv/rfc/ls012_optable.py @@ -77,19 +77,19 @@ def by_cost_then_priority_then_page(areas): costs[cost].append(row) return costs + # For prettier printing, replace short column heading # names with full, consistent names. # Expected input is a list of column strings def column_header_replacement(header): replacement_col = {'cost': 'XO Cost'} - new_header = header - for shortname in replacement_col.keys(): - # check if header contains any shortnames - if shortname in header: - index = header.index(shortname) - new_header[index] = replacement_col[shortname] + new_header = deepcopy(header) + for index, shortname in enumerate(replacement_col.keys()): + # update with replacement if any otherwise leave alone + new_header[index] = replacement_col.get(shortname, shortname) return new_header + def print_table(title, header, areas, sortby): fname = title.lower().replace(" ", "_") with open("ls012/%s.mdwn" % fname, "w") as f: