From 0e98fe6225cae992a954c061260994c070d8e600 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 1 Mar 2025 23:20:13 +0100 Subject: [PATCH] Auto line length --- git_time_tracker/format/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git_time_tracker/format/cli.py b/git_time_tracker/format/cli.py index c7d0313..0293c55 100644 --- a/git_time_tracker/format/cli.py +++ b/git_time_tracker/format/cli.py @@ -35,6 +35,7 @@ def fmt_line(label: Label, total_time: datetime.timedelta) -> str: label_str = str(label.label) return f' {label.category:20} {label_str:50} {hours:-4d}h {minutes:-2d}m' +LINE_LENGTH = len(fmt_line(Label('',''), datetime.timedelta())) def generate_report( samples: list[RealizedActivitySample], @@ -56,7 +57,7 @@ def generate_report( time_and_label.sort(reverse=True) # - yield '-' * 66 + yield '-' * LINE_LENGTH yield '\n' for total_time, label in time_and_label: if label.category == HIDDEN_LABEL_CATEGORY: @@ -69,7 +70,7 @@ def generate_report( yield '\n' del label, total_time - yield '-' * 66 + yield '-' * LINE_LENGTH yield '\n' label_total = Label(HIDDEN_LABEL_CATEGORY, 'total')