# HG changeset patch # User Sylvain Thénault # Date 1448285299 -3600 # Node ID 5ba4de264be4414f652e6cbbdf70777908ca3611 # Parent 53af91f77b9d2446af1c6f28848ee6c10e29246f [ldapfeed] simplify ldap2attrs * tdict argument is never given * separate value retrieval from setting output (will ease a latter cset) diff -r 53af91f77b9d -r 5ba4de264be4 sobjects/ldapparser.py --- a/sobjects/ldapparser.py Mon Nov 23 14:26:44 2015 +0100 +++ b/sobjects/ldapparser.py Mon Nov 23 14:28:19 2015 +0100 @@ -125,11 +125,13 @@ entity.cw_set(**attrs) self.notify_updated(entity) - def ldap2cwattrs(self, sdict, etype, tdict=None): - """ Transform dictionary of LDAP attributes to CW - etype must be CWUser or CWGroup """ - if tdict is None: - tdict = {} + def ldap2cwattrs(self, sdict, etype): + """Transform dictionary of LDAP attributes to CW. + + etype must be CWUser or CWGroup + """ + assert etype in ('CWUser', 'CWGroup'), etype + tdict = {} if etype == 'CWUser': items = self.source.user_attrs.items() elif etype == 'CWGroup': @@ -137,14 +139,13 @@ for sattr, tattr in items: if tattr not in self.non_attribute_keys: try: - tdict[tattr] = sdict[sattr] + value = sdict[sattr] except KeyError: - raise ConfigurationError('source attribute %s has not ' - 'been found in the source, ' - 'please check the %s-attrs-map ' - 'field and the permissions of ' - 'the LDAP binding user' % - (sattr, etype[2:].lower())) + raise ConfigurationError( + 'source attribute %s has not been found in the source, ' + 'please check the %s-attrs-map field and the permissions of ' + 'the LDAP binding user' % (sattr, etype[2:].lower())) + tdict[tattr] = value return tdict def before_entity_copy(self, entity, sourceparams):