@@ -64,9 +64,15 @@ def _multi_replace(string, replace_dict):
64
64
string = string .replace (str (key ), str (value ))
65
65
return string
66
66
67
+ def to_unicode_or_bust (obj , encoding = 'utf-8' ):
68
+ if isinstance (obj , basestring ):
69
+ if not isinstance (obj , unicode ):
70
+ obj = unicode (obj , encoding )
71
+ return obj
72
+
67
73
def _normalize (data_string , convert_whitespace = False ):
68
74
"Removes various markup artifacts and returns a normal python string."
69
- new_string = unescape (str (data_string ))
75
+ new_string = unescape (to_unicode_or_bust (data_string ))
70
76
new_string = _multi_replace (new_string , {
71
77
' ' : ' ' , '"' : '"' , '¦' : '|' , "'" : "'" , "\\ " : ""
72
78
})
@@ -343,6 +349,12 @@ def parse_ics(self, overwrite_events=True):
343
349
event_dict ["start_time" ] = _fix_timezone (event ["dtstart" ].dt , self .time_zone )
344
350
if "DTEND" in event :
345
351
event_dict ["end_time" ] = _fix_timezone (event ["dtend" ].dt , self .time_zone )
352
+ if event_dict ["start_time" ].hour == 0 \
353
+ and event_dict ["start_time" ].minute == 0 \
354
+ and (event_dict ["end_time" ] - event_dict ["start_time" ]) == timedelta (days = 1 ):
355
+ event_dict ["all_day" ] = True
356
+ else :
357
+ event_dict ["all_day" ] = False
346
358
347
359
event_dict ["repeats" ] = False
348
360
if "RRULE" in event :
@@ -355,13 +367,6 @@ def parse_ics(self, overwrite_events=True):
355
367
event_dict ["repeat_day" ] = event_dict ["start_time" ].day
356
368
event_dict ["repeat_month" ] = event_dict ["start_time" ].month
357
369
358
- if event_dict ["start_time" ].hour == 0 \
359
- and event_dict ["start_time" ].minute == 0 \
360
- and (event_dict ["end_time" ] - event_dict ["start_time" ]) == timedelta (days = 1 ):
361
- event_dict ["all_day" ] = True
362
- else :
363
- event_dict ["all_day" ] = False
364
-
365
370
if "BYDAY" in rep_dict :
366
371
event_dict ["repeat_day" ] = rep_dict ["BYDAY" ][0 ]
367
372
elif "BYMONTHDAY" in rep_dict :
0 commit comments