From 037e1d042fcbc2c9d19afee14316bbceab188080 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 27 Nov 2023 16:57:19 +0100 Subject: [PATCH 1/2] nethsm: Fix value length calculation in table formatting --- pynitrokey/cli/nethsm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pynitrokey/cli/nethsm.py b/pynitrokey/cli/nethsm.py index f1780f16..d07b9dae 100644 --- a/pynitrokey/cli/nethsm.py +++ b/pynitrokey/cli/nethsm.py @@ -76,8 +76,9 @@ def print_table(headers: Sequence[str], data: Iterable[Sequence[Any]]) -> None: for row in data: str_row = [] for i in range(len(widths)): - str_row.append(str(row[i])) - widths[i] = max(widths[i], len(row[i])) + str_value = str(row[i]) + str_row.append(str_value) + widths[i] = max(widths[i], len(str_value)) str_data.append(str_row) print_row(headers, widths) From cfbc6d65f9a14ee4dbed3798d58b95f2fb2620f1 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 27 Nov 2023 17:08:20 +0100 Subject: [PATCH 2/2] nethsm list-keys: Print enum values Instead of formatting the enum variant directly, print its value. --- pynitrokey/cli/nethsm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynitrokey/cli/nethsm.py b/pynitrokey/cli/nethsm.py index d07b9dae..42a82920 100644 --- a/pynitrokey/cli/nethsm.py +++ b/pynitrokey/cli/nethsm.py @@ -498,8 +498,8 @@ def list_keys(ctx: Context, details: bool, filter: Optional[str]) -> None: data.append( [ key_id, - key.type, - ", ".join([str(m) for m in key.mechanisms]), + key.type.value, + ", ".join([m.value for m in key.mechanisms]), key.operations, ", ".join(key.tags) if key.tags is not None else "", ]