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

Clarify how custom components should be parsed #432

Open
angatha opened this issue Oct 4, 2022 · 0 comments
Open

Clarify how custom components should be parsed #432

angatha opened this issue Oct 4, 2022 · 0 comments

Comments

@angatha
Copy link
Collaborator

angatha commented Oct 4, 2022

This issue arises from #417. See that PR for more context.

The test case from #417 uses icalendar.Calendar.from_ical(...) to parse a custom component. As for now (#417), that method is an effectively static class method. (It is a class method but doesn't use the cls argument.) It uses an instance of icalendar.cal.ComponentFactory to determine the class that represents the component, defaulting to icalendar.cal.Component.

What is the correct way of parsing a custom component?

Doing the analog of the current behavior, is one option. Calendar doesn't redefine from_ical(...) so actually the call is equivalent to icalendar.cal.Component.from_ical(...). A second option would be to model custom components with two new types. (Be welcome to add other solutions)

  • Use icalendar.cal.Component.from_ical(...) directly.
  • Introduce an XComponent and an IanaComponent (See RFC 5545)

Since currently there is no difference between icalendar.Calendar.from_ical(...) and icalendar.cal.Component.from_ical(...) when parsing an VCALENDAR (and other components), is it a feature, that they could be used interchangeable, is it a bug, that they don't validate the type or is it just undefined behavior when relying on the behavior of icalendar.Calendar.from_ical(...)? That should be clarified when documenting the new components (if that solution is chosen) but also it may be something to add for other components.

Steps to take

  1. clarify the questions from above
  2. implement chosen solution
  3. potentially adjust tests extracted from Split tests for custom components and calendar parsing #433
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant