summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2020-04-13 12:01:50 +0200
committerTobias Brox <tobias@redpill-linpro.com>2020-04-13 12:01:50 +0200
commitbb19781b3cc0f9b7e4730a807bd5c0d3f23ef371 (patch)
tree230fb004ff23a6df3fb9ebb6f2d11277f042d6c8
parentd8e5f2c3cb0e022abf60fe26e4997cd028a2821f (diff)
downloadcalendar-cli-bb19781b3cc0f9b7e4730a807bd5c0d3f23ef371.zip
Strings printed to stdout should not be utf-8-encoded. resolves https://github.com/tobixen/calendar-cli/issues/60
-rwxr-xr-xcalendar-cli.py6
-rwxr-xr-xtests/script_test.sh2
2 files changed, 4 insertions, 4 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index 77e33c2..27a037d 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -35,13 +35,13 @@ import sys
import re
import urllib3
from getpass import getpass
+from caldav.lib.python_utilities import to_normal_str
## ref https://github.com/tobixen/calendar-cli/issues/33, python3-compatibility
try:
raw_input
except NameError:
raw_input = input
- sys.stderr.write("here be dragons - calendar-cli is not properly tested for python3. See https://github.com/tobixen/calendar-cli/issues/33")
try:
unicode
@@ -526,7 +526,7 @@ def calendar_agenda(caldav_conn, args):
## TODO: this will probably break and is probably moot on python3?
for attr in vcal_txt_one + ['summary']:
if isinstance(event[attr], unicode):
- event[attr] = event[attr].encode('utf-8')
+ event[attr] = to_normal_str(event[attr])
print(args.event_template.format(**event))
def todo_select(caldav_conn, args):
@@ -670,7 +670,7 @@ def todo_list(caldav_conn, args):
t['uid'] = task.instance.vtodo.uid.value
## TODO: this will probably break and is probably moot on python3?
if hasattr(t['summary'], 'encode') and isinstance(t['summary'], unicode):
- t['summary'] = t['summary'].encode('utf-8')
+ t['summary'] = to_normal_str(t['summary'])
print(args.todo_template.format(**t))
def todo_complete(caldav_conn, args):
diff --git a/tests/script_test.sh b/tests/script_test.sh
index a32bc64..3a3f91a 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=4 --event-template='{uid}') ; do calendar_cli calendar delete --event-uid=$uid ; done
calendar_cli todo --categories scripttest delete
## TESTING