diff options
author | Tobias Brox <tobias@redpill-linpro.com> | 2018-12-17 10:56:55 +0100 |
---|---|---|
committer | Tobias Brox <tobias@redpill-linpro.com> | 2018-12-17 10:56:55 +0100 |
commit | f713dfd5b75faec29519b0601f05a0513a86340c (patch) | |
tree | 492356b069f094f71ae06407653cca6979f9ab46 | |
parent | 3a7827e0a08427b680b9eb5d0bf4795b5240065f (diff) | |
download | calendar-cli-f713dfd5b75faec29519b0601f05a0513a86340c.zip |
more fixing, ref https://github.com/tobixen/calendar-cli/issues/45
-rwxr-xr-x | calendar-cli.py | 9 | ||||
-rwxr-xr-x | tests/script_test.sh | 8 |
2 files changed, 10 insertions, 7 deletions
diff --git a/calendar-cli.py b/calendar-cli.py index 63c1cc6..d1843fa 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -488,17 +488,20 @@ def calendar_agenda(caldav_conn, args): event[timeattr] = event[timeattr].strftime(args.timestamp_format) else: event[timeattr] = '-' - for textattr in ('description', 'location'): + for textattr in vcal_txt_one: if hasattr(event['instance'], textattr): event[textattr] = getattr(event['instance'], textattr).value + else: + event[textattr] = '-' for summary_attr in ('summary', 'location', 'description'): if hasattr(event['instance'], summary_attr): event['summary'] = getattr(event['instance'], summary_attr).value break event['uid'] = event['instance'].uid.value if hasattr(event['instance'], 'uid') else '<no uid>' ## TODO: this will probably break and is probably moot on python3? - if isinstance(event['summary'], unicode): - event['summary'] = event['summary'].encode('utf-8') + for attr in vcal_txt_one + ['summary']: + if isinstance(event['summary'], unicode): + event['summary'] = event['summary'].encode('utf-8') print(args.event_template.format(**event)) def todo_select(caldav_conn, args): diff --git a/tests/script_test.sh b/tests/script_test.sh index d33a9d5..33f8530 100755 --- a/tests/script_test.sh +++ b/tests/script_test.sh @@ -25,7 +25,7 @@ calendar_cli() { ## CLEANUP from earlier failed test runs -for uid in $(../calendar-cli calendar agenda --from-time=2010-10-10 --agenda-days=1 --event-template='{uid}') ; do ../calendar-cli calendar delete --event-uid=$uid ; done +for uid in $($calendar_cli calendar agenda --from-time=2010-10-10 --agenda-days=1 --event-template='{uid}') ; do calendar_cli calendar delete --event-uid=$uid ; done ## TESTING @@ -39,7 +39,7 @@ echo "## Attempting to add a past event at 2010-10-09 20:00:00, 2 hours duration calendar_cli calendar add '2010-10-09 20:00:00+2h' 'testing testing' uid=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') echo "## Attempting to add a past event at 2010-10-10 20:00:00, CET (1 hour duration is default)" -calendar_cli calendar add '2010-10-10 20:00:00+01:00' 'testing testing' +calendar_cli calendar add '2010-10-10 20:00:00+01:00' 'testing testing' --set-description='this is a test calendar event' uid2=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') echo "## Attempting to add a past event at 2010-10-11 20:00:00, CET, 3h duration" calendar_cli calendar add '2010-10-11 20:00:00+01:00+3h' 'testing testing' @@ -47,8 +47,8 @@ uid3=$(echo $output | perl -ne '/uid=(.*)$/ && print $1') echo "## OK: Added the event, uid is $uid" echo "## Taking out the agenda for 2010-10-09 + four days" -calendar_cli calendar agenda --from-time=2010-10-09 --agenda-days=4 -echo $output | { grep -q 'testing testing' && echo "## OK: found the event" ; } || echo "## FAIL: didn't find the event" +calendar_cli calendar agenda --from-time=2010-10-09 --agenda-days=4 --event-template='{description}' +echo $output | { grep -q 'this is a test calendar event' && echo "## OK: found the event" ; } || echo "## FAIL: didn't find the event" echo "## Taking out the agenda for 2010-10-10, with uid" calendar_cli calendar agenda --from-time=2010-10-10 --agenda-days=1 --event-template='{dtstart} {uid}' |