1 # -*- coding: utf-8 -*-
4 ## This file is part of CDS Indico.
5 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7 ## CDS Indico is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU General Public License as
9 ## published by the Free Software Foundation; either version 2 of the
10 ## License, or (at your option) any later version.
12 ## CDS Indico is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ## General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22 Fixes possible encoding errors caused by older DB data
25 from MaKaC
.common
import DBMgr
26 from MaKaC
.conference
import ConferenceHolder
27 from indico
.util
.console
import conferenceHolderIterator
30 def fix_prop(c
, name
):
31 getter
= getattr(c
, 'get' + name
)
33 getter().decode('utf-8')
34 except UnicodeDecodeError:
36 getattr(c
, 'set' + name
)(getter().decode('latin1').encode('utf-8'))
39 def fix_everything(dbi
):
41 for level
, c
in conferenceHolderIterator(ConferenceHolder(), deepness
='event'):
43 fix_prop(c
, 'Description')
45 for spk
in c
.getChairList():
46 fix_prop(spk
, 'Affiliation')
47 fix_prop(spk
, 'FamilyName')
48 fix_prop(spk
, 'FirstName')
55 if __name__
== '__main__':
56 dbi
= DBMgr
.getInstance()