summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2020-06-08 00:12:18 +0200
committerTobias Brox <tobias@redpill-linpro.com>2020-06-08 00:12:18 +0200
commit18c896ad4eb7b6c2243f324bba3ae48cbf004309 (patch)
tree40b42c4ef55b7aa484cd60b9b41553eb5c8208fc
parent21e55e7c85fd9a072e6235f3169f8ce0a84bcac9 (diff)
downloadcalendar-cli-18c896ad4eb7b6c2243f324bba3ae48cbf004309.zip
python2/python3 string handling bugfixes
-rwxr-xr-xcalendar-cli.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index daf3866..f9d94e2 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
"""
calendar-cli.py - high-level cli against caldav servers
@@ -176,8 +176,7 @@ def _calendar_addics(caldav_conn, ics, uid, args):
try:
c = find_calendar(caldav_conn, args)
## unicode strings vs byte strings is a minefield in python3 ... so, re.search demands a string here ...
- if hasattr(ics, 'decode'):
- ics = ics.decode('utf-8')
+ ics = to_normal_str(ics)
if re.search(r'^METHOD:[A-Z]+[\r\n]+',ics,flags=re.MULTILINE) and args.ignoremethod:
ics = re.sub(r'^METHOD:[A-Z]+[\r\n]+', '', ics, flags=re.MULTILINE)
print ("METHOD property found and ignored")
@@ -666,7 +665,7 @@ def todo_list(caldav_conn, args):
tasks = todo_select(caldav_conn, args)
if args.icalendar:
for ical in tasks:
- print(ical.data.encode('utf-8'))
+ print(to_normal_str(ical.data))
elif args.list_categories:
categories = set()
for task in tasks:
@@ -688,9 +687,7 @@ def todo_list(caldav_conn, args):
t['summary'] = getattr(task.instance.vtodo, summary_attr).value
break
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'] = to_normal_str(t['summary'])
+ t['summary'] = to_normal_str(t['summary'])
print(args.todo_template.format(**t))
def todo_complete(caldav_conn, args):