From f5c39076fd6164d1057d862002bb3826bb610b4c Mon Sep 17 00:00:00 2001 From: George Lacey Date: Mon, 3 May 2021 18:01:57 +0100 Subject: [PATCH] Strip lines correctly --- src/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.py b/src/main.py index a9cd375..12f4956 100644 --- a/src/main.py +++ b/src/main.py @@ -17,22 +17,23 @@ def create_log_entry(raw_borg_output: list): attributes = {"Archive name: ": "", "Archive fingerprint: ": "", "Time (start): ": "", + "Time (end): ": "", "Duration: ": "", "Number of files: ": ""} - for i in range(0, len(raw_borg_output)): + for line in raw_borg_output: for key in attributes: - if raw_borg_output[i].startswith(key): - attributes[key] = raw_borg_output[i] \ - .strip(key) \ - .rstrip() + if line.startswith(key): + attributes[key] = line[len(key):].strip() return LogEntry(attributes["Archive name: "], attributes["Archive fingerprint: "], attributes["Time (start): "], + attributes["Time (end): "], attributes["Duration: "], attributes["Number of files: "]) if __name__ == "__main__": - main(stdin.readlines()) + input_text = stdin.readlines() + main(input_text)