icalevents
icalevents copied to clipboard
showing deleted events
I wrote a script to get today's event from the team calendar on Confluence. The script downloads the ics file, then uses the icalevents to parse. I noticed that it shows the event that has been already deleted. The event is one instance of a recurring event.
Here is the script: https://github.com/jc1518/myscripts/blob/master/python-scripts/confluence/team_ics.py
Just did a big digging, I think the issue is that the module does not handle EXDATE.
I have added a quick fix in my local icalparser.py file (function parse_events), and it works for me so far. My code is not elegant though ;)
for component in calendar.walk():
i = 0
if component.name == "VEVENT":
if component.get('rrule'):
if component.get('exdate'):
#print("----------------------------------------------")
#print(vDatetime(datetime.today()).to_ical())
if isinstance(component.get('exdate'), list):
for exdate in component.get('exdate'):
#print(str(exdate.to_ical()))
if str(exdate.to_ical()).replace("'", "") in str(vDatetime(datetime.today()).to_ical()).replace("'",""):
#print("+++++++++++++++++++++++++")
#print("Today is exception date")
#print(component)
i += 1
else:
#print(component.get('exdate').to_ical())
if str(component.get('exdate').to_ical()).replace("'", "") in str(vDatetime(datetime.today()).to_ical()).replace("'",""):
#print("+++++++++++++++++++++++++")
#print("Today is exception date")
#print(component)
i += 1
if i == 0:
es = create_recurring_events(start, end, component)
if es:
found += es
else:
e = create_event(component)
if e.end >= start and e.start <= end:
found.append(e)
return found
`
Should be fixed in v0.1.8
@jc1518 can you check?
@PabloCastellano No, it does not fix it.
Hm, that's odd, it worked for my EXDATEs... There is now even a unittest for EXDATE handling, which turns out positive. Could you recheck with v0.1.11, and maybe post some example ics code where EXDATE parsing fails?
@PabloCastellano , @dlichtistw, I think it is caused by that the tz is missed in the extract_exdates function.
It should be:
def extract_exdates(component, tz=UTC):
"""
Compile a list of all exception dates stored with a component.
:param component: icalendar iCal component
:return: list of exception dates
"""
dates = []
exd_prop = component.get('exdate')
if exd_prop:
if isinstance(exd_prop, list): # In case there is more than one exdate property
for exd_list in exd_prop:
dates.extend(normalize(exd.dt, tz=tz) for exd in exd_list.dts)
elif isinstance(exd_prop, vDDDLists):
dates.extend(normalize(exd.dt, tz=tz) for exd in exd_prop.dts)
return dates
should be fixed. If not feel free to reopen :-)