From 96e6c0f463523fb5c287e8d05e9dcbfb967d6ae4 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 19 May 2016 16:09:24 +0200 Subject: [PATCH] use sn/givenName/cn attributes --- curie/curie2supann.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/curie/curie2supann.py b/curie/curie2supann.py index 3237d32..3cfe07d 100755 --- a/curie/curie2supann.py +++ b/curie/curie2supann.py @@ -124,8 +124,18 @@ class CurieLdifParser(ldif.LDIFParser): assert ic_entite in ('Recherche', 'Hopital', 'SI'), \ 'valeur d\'ICEntite inconnue: %s' % ic_entite supann_entite_affectation = ic_entite - prenom = self.assert_sv_attribute(entry, 'icprenomnaissance') - nom = self.assert_sv_attribute(entry, 'icnomnaissance') + if 'icprenomnaissance' in entry: + prenom = self.assert_sv_attribute(entry, 'icprenomnaissance') + else: + prenom = self.assert_sv_attribute(entry, 'givenname') + if 'icnomnaissance' in entry: + nom = self.assert_sv_attribute(entry, 'icnomnaissance') + else: + nom = self.assert_sv_attribute(entry, 'sn') + if 'cn' in entry: + cn = self.assert_sv_attribute(entry, 'cn') + else: + cn = strip_accents('%s %s' % (prenom, nom)).strip() telephone = entry.get('telephoneNumber', []) mail = entry.get('mail', []) if ic_entite == 'Recherche': @@ -141,7 +151,7 @@ class CurieLdifParser(ldif.LDIFParser): 'uid': uid, 'sn': nom, 'givenName': prenom, - 'cn': strip_accents('%s %s' % (prenom, nom)).strip(), + 'cn': cn, 'mail': mail, } if supann_entite_affectation: