ics con accenti (solo py3)

This commit is contained in:
boyska 2018-07-01 16:58:26 +02:00
parent d3eee582a8
commit 5a6e68909a

View file

@ -180,7 +180,8 @@ def get_talk_data(talkname):
def overlap(interval_a, interval_b): def overlap(interval_a, interval_b):
'''how many minutes do they overlap?''' '''how many minutes do they overlap?'''
return max(0, min(interval_a[1], interval_b[1]) - max(interval_a[0], interval_b[0])) return max(0, min(interval_a[1], interval_b[1]) -
max(interval_a[0], interval_b[0]))
def get_talk_overlaps(name): def get_talk_overlaps(name):
@ -376,12 +377,18 @@ def talks_to_ics():
def talk_to_ics(talk): def talk_to_ics(talk):
def _decode(s):
if six.PY2:
return unidecode.unidecode(s)
else:
return s
if 'time' not in talk or 'duration' not in talk: if 'time' not in talk or 'duration' not in talk:
return None return None
e = ics.Event( e = ics.Event(
uid="%s@%d.hackmeeting.org" % (talk['id'], uid="%s@%d.hackmeeting.org" % (talk['id'],
get_global_data()['startdate'].year), get_global_data()['startdate'].year),
name=unidecode.unidecode(talk['title']), name=_decode(talk['title']),
begin=talk['time'], begin=talk['time'],
duration=datetime.timedelta(minutes=talk['duration']), duration=datetime.timedelta(minutes=talk['duration']),
transparent=True, transparent=True,
@ -390,7 +397,7 @@ def talk_to_ics(talk):
# unidecode replaces letters with their most similar ASCII counterparts # unidecode replaces letters with their most similar ASCII counterparts
# (ie: accents get stripped) # (ie: accents get stripped)
if 'text' in talk: if 'text' in talk:
e.description = unidecode.unidecode(talk['text']) e.description = _decode(talk['text'])
e.url = pelican.settings['SCHEDULEURL'] + '#talk-' + talk['id'] e.url = pelican.settings['SCHEDULEURL'] + '#talk-' + talk['id']
if 'room' in talk: if 'room' in talk:
e.location = talk['room'] e.location = talk['room']