Commit 44949772 authored by Jan Kiene's avatar Jan Kiene
Browse files

refactor display string creation function

parent 45d7abe9
Loading
Loading
Loading
Loading
+26 −30
Original line number Diff line number Diff line
@@ -248,20 +248,7 @@ def main(wmops_log, wmops_per_op_log, rom_log, ram_log):
        runs = [
            create_runs_string(line.strip().split(split_char), x) for line in log_lines
        ]

        display_ids = DISPLAY_IDS[x]
        display_line_idx = DISPLAY_LINE_IDX[x]
        line_colors = LINE_COLORS[x]
        display_labels = DISPLAY_LABELS.get(x, [""] * len(display_ids))
        # TODO: can be refactored now that x is passed
        displays = [
            create_display_string(
                log_lines, id, idx, color, data["references"], split_char, label, x
            )
            for id, idx, color, label in zip(
                display_ids, display_line_idx, line_colors, display_labels
            )
        ]
        displays = create_display_strings(log_lines, data["references"], split_char, x)

        runs = ",\n".join(runs)
        displays = ",\n".join(displays)
@@ -288,8 +275,15 @@ def create_runs_string(line: list[str], which: str) -> str:
    return run


def create_display_string(
    log_lines, id, idx, color, references, split_char, label, which
def create_display_strings(log_lines, references, split_char, which):
    display_ids = DISPLAY_IDS[which]
    display_line_idx = DISPLAY_LINE_IDX[which]
    line_colors = LINE_COLORS[which]
    display_labels = DISPLAY_LABELS.get(which, [""] * len(display_ids))

    displays = list()
    for id, idx, color, label in zip(
        display_ids, display_line_idx, line_colors, display_labels
    ):
        data = list()
        for i, line in enumerate(log_lines):
@@ -306,7 +300,9 @@ def create_display_string(
            label_string = f"label: '{label}', "
            display = display[:idx_data] + label_string + display[idx_data:]

    return display
        displays.append(display)

    return displays


if __name__ == "__main__":