Strip lines correctly

This commit is contained in:
George Lacey 2021-05-03 18:01:57 +01:00
parent 9e053c715d
commit f5c39076fd

View File

@ -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)