-
Notifications
You must be signed in to change notification settings - Fork 126
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
ENH: add support for calendar name #312
Conversation
Right now it fails to register. Although I can see that def post_populate(self, component: Component, context: ContextDict):
if self.is_required and not context[(self, "current_value_count")]:
> raise ValueError("attribute %s is required but got no value" % self.ics_name)
E ValueError: attribute NAME is required but got no value |
@N-Coder @C4ptainCrunch could you have a look? 😃 |
Also move timezone to root of yaml file This will eventually be supported through ics-py/ics-py#312, but this is a quick workaround in the interim.
Also move timezone to root of yaml file This will eventually be supported through ics-py/ics-py#312, but this is a quick workaround in the interim.
Also move timezone to root of yaml file This will eventually be supported through ics-py/ics-py#312, but this is a quick workaround in the interim.
Hi @tupui 👋 Sorry for the delay. First, thanks a lot for taking the time to submit a PR, you rock 🤘 I did not have a lot of time to look at your PR yet but i do have a question: Why do you add a default value for the calendar name ? Shouldn't we just keep it null if we did not get any data (and not writing a UPDATE: I had a closer look and fiddled a bit with your code. My changes are available in 8761dfc if you want. I hope it unsticks you :) |
No worries!
I thought a calendar should be named, but no problem to make this completely optional and not present if not specified.
Oh thanks! I will apply your changes then 😃 |
@@ -62,4 +63,24 @@ def serialize(self, component: Component, output: Container, context: ContextDic | |||
context["VTIMEZONES_AFTER"] = len(output) | |||
|
|||
|
|||
class CalendarNameConverter(GenericConverter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we can then remove all changes to this file then? Actually this still required for X-WR-CALNAME
rewrite to point to NAME
.
Sorry I did not get the optional
validator. I had trouble to understand how these were working together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we can then remove all changes to this file then?
yes, please do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we don't have X-WR-CALNAME
at all if we do this. Shouldn't we try to always add X-WR-CALNAME
to have both fields?
To me what is missing here is just adding NAME
to an extra field X-WR-CALNAME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have this in CalendarNameConverter.populate
if item.name == "NAME":
component.extra_params["X-WR-CALNAME"] = item.value
return True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make the tests pass, but I am probably not doing it right, you're probably better of doing this yourself at this point 😄
tests/test_calendar.py
Outdated
# FIXME: what behavior should we expect here? | ||
# FIXME: In both cases, we need a test and we need to document it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the RFC is only referring to NAME
, I suppose one could say that if both fields are present, it should take NAME instead of X-WR-CALNAME. This is what I've done now.
Great ! This looks in good shape to be merged 🎉 But first, could you :
|
Thanks @C4ptainCrunch! Where do you want me do document this? I am not sure as to where this would fit better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for making the effort to get your way around my Converter system and creating this PR - and sorry for taking my time to reply! Unfortunately, your code doesn't quite do what you intended, see my reviews. I see this as another argument for the Converter system being in desperate need of some refactoring and especially bigger simplifications. I guess the simplest way forward here would be using the following implementation for your propagate
, adding handling of conflicting specifications later on once the Converter system makes that easier to do:
def populate(self, component: Component, item: ContainerItem, context: ContextDict) -> bool:
component.name = item.value
return False
One thing that should be noted: with this PR, the library will now throw an exception when it sees multiple values for name, e.g. because they were localized, while before the multiple values could be stored to the extra properties just fine. This the second big "construction site", where the library is too strict in many cases. But I guess supporting one one name for now is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @N-Coder!
As I said bellow, I just came across the fact that we would need X-WR-CALNAME for practical reason.
@C4ptainCrunch @N-Coder Let me know what should be the behaviour. I personally would go with providing both fields (either another attribute or in extra) and NAME would take precedence over X-WR-CALNAME to follow a bit more the RFC.
I guess the best way to support this would be parsing both values into the same field Unfortunately, we don't have that yet and it only adds to the complexity of refactoring the (de-)serialization system, so it will probably also take a while. In the meantime, I'd say the sanest thing to do is add a |
@N-Coder This is the current behaviour implemented in this PR no? |
If you remove the added |
@tupui: are you still interested in working on this PR ? Could you have a look at the failing test ? :) |
I am interested but as you've seen, you or @N-Coder would just be faster finishing this up vs discussing what I should do. I am afraid I don't have much time to focus on the architecture of the package to make this right. |
I'm closing this due to the previous comment. Anybody can reopen if they have time to work on this :) |
This felt like an important issue. We can work around it, as we've been doing, but calendars without names are much less useful for importing on eg Google Calendar. If the PR is closed, shouldn't an issue at least be opened? |
Closes #307
NAME
andX-WR-CALNAME
support.X-WR-CALNAME
is converted toNAME
andX-WR-CALNAME
is added in extras.(For the backstory, I talked about this with @stefanv)