Add conversion tables for wrongly formatted deputies/ministries

This commit is contained in:
Frédéric Péters 2011-07-28 16:12:37 +02:00
parent a74e01ca6d
commit 5ae8972fff
1 changed files with 33 additions and 5 deletions

View File

@ -21,7 +21,10 @@ class Migrate(BrowserView):
return 'Missing filename\n'
fd = file(os.path.join('/tmp/', filename))
else:
fd = cStringIO.StringIO(self.request.form['data'])
try:
fd = cStringIO.StringIO(self.request.form['data'])
except KeyError:
return 'Missing data\n'
doc = cPickle.load(fd)
portal = getToolByName(self.context, 'portal_url').getPortalObject()
@ -198,6 +201,10 @@ class Migrate(BrowserView):
plone_tool = getToolByName(self.context, 'plone_utils')
portal = getToolByName(self.context, 'portal_url').getPortalObject()
author = unicode(author, 'utf-8')
author = {
u'de Donn\xe9a Fran\xe7ois-Xavier': u'de Donn\xe9a, Fran\xe7ois-Xavier',
u'Doulkeridis Christos': u'Doulkeridis, Christos',
}.get(author, author)
author_id = plone_tool.normalizeString(author)
if author_id == 'college':
return 'ministry:college'
@ -223,10 +230,31 @@ class Migrate(BrowserView):
plone_tool = getToolByName(self.context, 'plone_utils')
portal = getToolByName(self.context, 'portal_url').getPortalObject()
author = unicode(author, 'utf-8')
if len(author.split()) > 3:
if not 'Warnaffe' in author and \
not 'Jonghe' in author:
print >> self.logfile, 'W: author with (too?) many parts: %r' % author
author = {
u'Brotchi Jacques': u'Brothi, Jacques',
u'De Bock Emmanuel': u'De Bock, Emmanuel',
u'Defoss\xe9 Jean-Claude': u'Defoss\xe9, Jean-Claude',
u"d'Ursel Anne Charlotte": u"d'Ursel, Anne Charlotte",
u'El Khannouss Ahmed': u'El Khannouss, Ahmed',
u'Ikazban Jamal': u'Ikazban, Jamal',
u'Lurquin Vincent': u'Lurquin, Vincent',
u'Mandaila Gis\xe8le': u'Mandaila, Gis\xe8le',
u'Maron Alain': u'Maron, Alain',
u'Migisha Pierre': u'Migisha, Pierre',
u'Morel Jacques': u'Morel, Jacques',
u'Mouhssin Ahmed': u'Mouhssin, Ahmed',
u'Moureaux Catherine': u'Moureaux, Catherine',
u'Ouriaghli Mohamed': u'Ouriaghli, Mohamed',
u'Ozdemir Mahinur': u'Ozdemir, Mahinur',
u'Pinxteren Arnaud': u'Pinxteren, Arnaud',
u'Sessler Patrick': u'Sessler, Patrick',
u'Sidibe Fatoumata': u'Sidibe, Fatoumata',
u'Trachte Barbara': u'Trachte, Barbara',
u'Van Goidsenhoven Ga\xebtan': u'Van Goidsenhoven, Ga\xebtan',
u'Vanhalewyn Vincent': u'Vanhalewyn, Vincent',
u'Willame Boonen Magdeleine': u'Willame Boonen, Magdeleine',
u'Govers, Pascale, ': u'Govers, Pascale',
}.get(author, author)
author_id = plone_tool.normalizeString(author)
if not portal.deputes.has_key(author_id):
workflow_tool = getToolByName(self.context, 'portal_workflow')