From 83b81c08aadd31cfbdf43b537faa715dbaa7e9b4 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 9 Mar 2023 09:08:25 +0900 Subject: [PATCH] Fixing multiple PRODID lines --- calcure/configuration.py | 2 +- calcure/loaders.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/calcure/configuration.py b/calcure/configuration.py index 6f9fe23..44b1614 100644 --- a/calcure/configuration.py +++ b/calcure/configuration.py @@ -99,7 +99,7 @@ def create_config_file(self): "color_active_pane": "2", "color_separator": "7", "color_calendar_border": "7", - "color_ics_calendars": "2,3,1,7", + "color_ics_calendars": "2,3,1,7,4,5,2,3,1,7", "color_background": "-1", } diff --git a/calcure/loaders.py b/calcure/loaders.py index 6984b59..d5b044a 100644 --- a/calcure/loaders.py +++ b/calcure/loaders.py @@ -224,14 +224,16 @@ class LoaderICS: def read_lines(self, file): """Read the file line-by-line and remove multiple PRODID lines""" - previous_line = "" + already_has_prodid = False text = "" for line in file: # If there is more than one PRODID line or a TZUNTIL line, skip them: - if (not ("PRODID:" in line and "PRODID:" in previous_line) and - not ("TZUNTIL" in line)): + if ((not (already_has_prodid and "PRODID:" in line)) and + (not "TZUNTIL" in line)): text += line - previous_line = line + + if "PRODID:" in line: + already_has_prodid = True return text def read_file(self, path):