From 87d90b49827f61c4ec666c1c53820c75d336be5e Mon Sep 17 00:00:00 2001 From: Abe Hanoka Date: Tue, 10 Dec 2024 09:58:45 -0500 Subject: [PATCH] fix inline examples --- src/icalendar/cal.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/icalendar/cal.py b/src/icalendar/cal.py index 209e5bc0..9334e461 100644 --- a/src/icalendar/cal.py +++ b/src/icalendar/cal.py @@ -613,10 +613,14 @@ def from_file(cls, file: Union[str, Path], multiple: bool = False): Example: >>> from icalendar import Calendar + >>> from pathlib import Path >>> # Read a calendar file >>> cal = Calendar.from_file("src/icalendar/tests/calendars/example.ics") >>> # Read multiple calendars >>> cals = Calendar.from_file("src/icalendar/tests/calendars/multiple_calendar_components.ics", multiple=True) + >>> # or pass a Path object + >>> path = Path("src/icalendar/tests/calendars/example.ics") + >>> cal = Calendar.from_file(path) """ # Handle string path by converting to Path if isinstance(file, str): @@ -637,15 +641,13 @@ def to_file(self, file: Union[str, Path], sorted: bool = True) -> None: sorted: Whether parameters and properties should be lexicographically sorted. Example: - >>> from icalendar import Calendar - >>> from pathlib import Path - >>> # Read a calendar file - >>> cal = Calendar.from_file("src/icalendar/tests/calendars/example.ics") - >>> # or pass a Path object - >>> path = Path("src/icalendar/tests/calendars/example.ics") - >>> cal = Calendar.from_file(path) - >>> # Read multiple calendars - >>> cals = Calendar.from_file("src/icalendar/tests/calendars/multiple_calendar_components.ics", multiple=True) + >>> from icalendar import Calendar, Event + >>> # Write a calendar + >>> cal = Calendar() + >>> cal.to_file("calendar.ics") + >>> # Write an event + >>> event = Event() + >>> event.to_file("event.ics") """