collective / icalendar

icalendar parser library for Python
https://icalendar.readthedocs.io/en/latest/
Other
981 stars 168 forks source link

Feature request: support event deletion #620

Open HDembinski opened 4 months ago

HDembinski commented 4 months ago

Thanks for providing this library. Surprisingly, it does not offer an easy way to delete events from a calendar. There is nothing about deleting events in the documentation, and I only found this unhelpful SO entry.

The Calendar class mimics the dict interface, but does not support item removal as a dict would. I think it should, it is unpythonic.

Please add support for item removal, thanks!

stevepiercy commented 4 months ago

Would this suggestion address your need? https://github.com/collective/icalendar/issues/125

niccokunzmann commented 4 months ago

Let's close this when the documentation is updated on how to delete events. #125 is a good start.

HDembinski commented 4 months ago

Thank you for the pointer, I see now how it is possible. Thank you for considering updating the documentation. It is not clear to me why one has to use the subcomponents property. Wouldn't it be more intuitive to support del calendar[key]? You are imitiating a dict interface.

niccokunzmann commented 4 months ago

There are components that do not necessarily have a key and there are key/value pairs.

If you found out how to delete a specific event, would you like to report the code back and we can put something that is understandable by newcomers into the documentation?

Also, if you have an idea and example code of how you would like to use the del calendar[key] and other dict interface methods to work on events in a nicer way, could you post that as a new discussion.