Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to read calendars from files #756

Open
4 tasks
niccokunzmann opened this issue Dec 9, 2024 · 2 comments · May be fixed by #757
Open
4 tasks

Allow to read calendars from files #756

niccokunzmann opened this issue Dec 9, 2024 · 2 comments · May be fixed by #757

Comments

@niccokunzmann
Copy link
Member

niccokunzmann commented Dec 9, 2024

In order to make it nicer to use the icalendar interface, we can add these two types to icalendar.Calendar.from_ical():

  • pathlib.Path
  • str

In both cases, we assume a path is given.

Implementation suggestion

  • translate str into Path
  • use Path.read_bytes() to get the content that would usually be passed to the from_ical()
  • document all the parameters, see Which docstring format should we use? #747
  • Test it with Path and with str

Context

Usually, these are .ics files. As such, the other components do not need that feature.

@abe-101
Copy link
Collaborator

abe-101 commented Dec 9, 2024

I propose adding a new method to the Calendar object
icalendar.Calendar.from_file()

and the method will open the provided file and pass the content to
icalendar.Calendar.from_ical()

@abe-101
Copy link
Collaborator

abe-101 commented Dec 9, 2024

I think we can do the same for icalendar.Calendar.to_ical()
a new method called icalendar.Calendar.to_file() that excepts a path and uses to_ical() and write it to the given path

@abe-101 abe-101 linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants