ungana

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README

commit 3ea98dff08c795d961c7744f6ad88241a72f862d
parent 0a95a8a2bef159c55da7aa97865d962bfed294e6
Author: Carlosokumu <carlosokumu254@gmail.com>
Date:   Tue, 19 Aug 2025 14:57:02 +0300

update ICalManager's update_event method to handle attachment updates for long and poster

Diffstat:
Mcalendarapp/ical/ical_manager.py | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/calendarapp/ical/ical_manager.py b/calendarapp/ical/ical_manager.py @@ -43,22 +43,24 @@ class ICalManager: return event - - def update_event(self, cal: Calendar, updates: Dict[str, Any],filename: str = None) -> Calendar: - uid = cal.walk('VEVENT')[0].get('uid') + def update_event(self,cal: Calendar,updates: Dict[str, Any],attachments: list = None,filename: str = None) -> Calendar: + uid = cal.walk("VEVENT")[0].get("UID") event_found = False for component in cal.walk(): if component.name == "VEVENT" and str(component.get("UID")) == uid: event_found = True for key, value in updates.items(): component[key] = value + if attachments: + for prop, value, params in attachments: + component.add(prop, value, parameters=params) + break if not event_found: raise ValueError(f"No event with UID {uid} found.") - if filename: - self.update_ical_file(cal,filename) + self.update_ical_file(cal, filename) return cal @@ -119,6 +121,8 @@ class ICalManager: def update_ical_file(self, cal: Calendar, filename: str) -> None: + ical_bytes = cal.to_ical() + unfolded = ical_bytes.replace(b"\r\n ", b"").replace(b"\n ", b"") with open(filename, 'wb') as f: - f.write(cal.to_ical()) + f.write(unfolded)