ya3

ya3 -- yet another appointment application
Log | Files | Refs

commit b920106089f4fb627521643fdab4edc4d60cd061
parent 1c8c7e6d58fb15795d8ee99f3c9b2a3b03001ad0
Author: Matthias Balk <mbalk@mbalk.de>
Date:   Sun, 23 Sep 2018 11:09:25 +0200

Support more than one vevent in a vcalendar when printing

Diffstat:
Mcommands.py | 31++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/commands.py b/commands.py @@ -75,18 +75,19 @@ def _conv2local(dt): def print_events(icsfilename): with open(icsfilename) as f: - for event in vobject.readComponents(f): - start = _conv2local(event.vevent.dtstart.value) - end = _conv2local(event.vevent.dtend.value) - - try: - location = " (" + event.vevent.location.value + ")" - except AttributeError: - location = "" - - if start >= datetime.now(gettz()) - config.MAX_AGE and \ - start < datetime.now(gettz()) + config.MAX_AHEAD: - print('%s - %s %s%s' % (start.strftime('%Y-%m-%d %H:%M'), - end.strftime('%H:%M'), - event.vevent.summary.value, - location)) + for cal in vobject.readComponents(f): + for event in cal.vevent_list: + start = _conv2local(event.dtstart.value) + end = _conv2local(event.dtend.value) + + try: + location = " (" + event.location.value + ")" + except AttributeError: + location = "" + + if start >= datetime.now(gettz()) - config.MAX_AGE and \ + start < datetime.now(gettz()) + config.MAX_AHEAD: + print('%s - %s %s%s' % (start.strftime('%Y-%m-%d %H:%M'), + end.strftime('%H:%M'), + event.summary.value, + location))