From a8797a4ce85725ebe084de37d7834759d24d1e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 1 Dec 2011 18:12:40 +0100 Subject: [PATCH] parse locations set as email addresses by zimbra (#1093) --- tabellio/icalimport/icalimport.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tabellio/icalimport/icalimport.py b/tabellio/icalimport/icalimport.py index 884b9bd..405f27c 100644 --- a/tabellio/icalimport/icalimport.py +++ b/tabellio/icalimport/icalimport.py @@ -1,6 +1,9 @@ +# -*- coding: utf-8 -*- + import datetime import urllib2 import vobject +import rfc822 from zope import component from zope.event import notify @@ -57,6 +60,17 @@ class IcalImport(BrowserView): except: pass + if location and '@' in location: + try: + location, email = rfc822.parseaddr(location) + except: + pass + + if location: + # some special substitutions for PCF common locations + location = location.replace(u'HL ', u'Hôtel de Ligne - ') + location = location.replace(u'HG ', u'Hôtel du Greffe - ') + base_id = '%(year)04d%(month)02d%(day)02d' base_parts = {'year': date_start.year, 'month': date_start.month,