ics-py / ics-py

Pythonic and easy iCalendar library (rfc5545)

Home Page:http://icspy.readthedocs.org/en/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`.summary` does not set the event name

AirbandAF opened this issue · comments

Hi,

I've just installed this package and I have run into a couple of issues. I am on version 0.7.2 and using Python 3.10.5 on a Mac (OSX 12.1)
I used the code given in the example to create an event:

c = Calendar()
e = Event()
e.summary = "My cool event"
e.description = "A meaningful description"
e.begin = dt.datetime.fromisoformat("2022-06-06T12:05:23+02:00")
e.end = dt.datetime.fromisoformat("2022-06-06T13:05:23+02:00")
c.events.append(e)
c

However, on running this I get the following error:
AttributeError: 'set' object has no attribute 'append'

This can be fixed by replacing with events.add instead of .append.

However, inspite of this, the resulting ics does not contain an event name. This is true both when printing the object and writing to the file.

The resulting object is this:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:ics.py - http://git.io/lLljaA
BEGIN:VEVENT
DESCRIPTION:A meaningful description
DTEND:20220606T110523Z
DTSTART:20220606T100523Z
UID:11c1c292-de41-4fa7-915a-48aaf85d09d8@11c1.org
END:VEVENT
END:VCALENDAR

I'm not sure if I'm doing something wrong or there is an issue with the code.

commented

Hi,

Indeed, you should use .add and not .append, it seems you are using an old introduction snippet (the doc seems up to date https://icspy.readthedocs.io/en/stable/#create-a-new-calendar-and-add-events)

For the missing name part : to set an event name, you should use e.name = 'xxx' not e.summary. We made the choice to use the more common "name" property and not "summary" that requires you to know the terminology of the RFC5545.
Edit: we might want to raise a warning if someone tries to set summary, it seems an easy mistake to make.

Does this solve your problem ?

PS: where did you find the snippet containing .append ? It could be nice if we could fix it too.

Hi,

Indeed, you should use .add and not .append, it seems you are using an old introduction snippet (the doc seems up to date https://icspy.readthedocs.io/en/stable/#create-a-new-calendar-and-add-events)

For the missing name part : to set an event name, you should use e.name = 'xxx' not e.summary. We made the choice to use the more common "name" property and not "summary" that requires you to know the terminology of the RFC5545. Edit: we might want to raise a warning if someone tries to set summary, it seems an easy mistake to make.

Does this solve your problem ?

PS: where did you find the snippet containing .append ? It could be nice if we could fix it too.

I discovered this project on https://pypi.org/project/ics/, clicking the Documentation link under the first paragraph of Project Description will redirect to https://icspy.readthedocs.io/en/v0.8.0-dev0/ which has the .append and .summary.

I suggest having https://icspy.readthedocs.io/ redirect to the docs for latest stable instead.

commented

@LemuelKL Oh, nice catch. This is a side effect of me trying to release a pre-release this morning, indeed, readthedocs should point to stable instead. I'll try to fix that.

Hi,
Thanks very much for your help! This makes sense now.
I also went through pypi and that is how I found the docs, I thought I was going crazy as I was following the docs exactly but it wasn't working.