More pep8 fixes to remove deprecated functions

This commit is contained in:
Ryan Lane
2010-12-08 00:34:20 +00:00
parent df1bfc7c86
commit 5ee84cd303

View File

@@ -138,19 +138,19 @@ class LdapDriver(object):
# Entry could be malformed, test for missing attrs. # Entry could be malformed, test for missing attrs.
# Malformed entries are useless, replace attributes found. # Malformed entries are useless, replace attributes found.
attr = [] attr = []
if user.has_key('secretKey'): if 'secretKey' in user.keys():
attr.append((self.ldap.MOD_REPLACE, 'secretKey', \ attr.append((self.ldap.MOD_REPLACE, 'secretKey', \
[secret_key])) [secret_key]))
else: else:
attr.append((self.ldap.MOD_ADD, 'secretKey', \ attr.append((self.ldap.MOD_ADD, 'secretKey', \
[secret_key])) [secret_key]))
if user.has_key('accessKey'): if 'accessKey' in user.keys():
attr.append((self.ldap.MOD_REPLACE, 'accessKey', \ attr.append((self.ldap.MOD_REPLACE, 'accessKey', \
[access_key])) [access_key]))
else: else:
attr.append((self.ldap.MOD_ADD, 'accessKey', \ attr.append((self.ldap.MOD_ADD, 'accessKey', \
[access_key])) [access_key]))
if user.has_key('isAdmin'): if 'isAdmin' in user.keys():
attr.append((self.ldap.MOD_REPLACE, 'isAdmin', \ attr.append((self.ldap.MOD_REPLACE, 'isAdmin', \
[str(is_admin).upper()])) [str(is_admin).upper()]))
else: else:
@@ -298,13 +298,13 @@ class LdapDriver(object):
attr = [] attr = []
# Retrieve user by name # Retrieve user by name
user = self.__get_ldap_user(uid) user = self.__get_ldap_user(uid)
if user.has_key('secretKey'): if 'secretKey' in user.keys():
attr.append((self.ldap.MOD_DELETE, 'secretKey', \ attr.append((self.ldap.MOD_DELETE, 'secretKey', \
user['secretKey'])) user['secretKey']))
if user.has_key('accessKey'): if 'accessKey' in user.keys():
attr.append((self.ldap.MOD_DELETE, 'accessKey', \ attr.append((self.ldap.MOD_DELETE, 'accessKey', \
user['accessKey'])) user['accessKey']))
if user.has_key('isAdmin'): if 'isAdmin' in user.keys():
attr.append((self.ldap.MOD_DELETE, 'isAdmin', \ attr.append((self.ldap.MOD_DELETE, 'isAdmin', \
user['isAdmin'])) user['isAdmin']))
self.conn.modify_s(self.__uid_to_dn(uid), attr) self.conn.modify_s(self.__uid_to_dn(uid), attr)
@@ -513,8 +513,8 @@ class LdapDriver(object):
"""Convert ldap attributes to User object""" """Convert ldap attributes to User object"""
if attr is None: if attr is None:
return None return None
if (attr.has_key('accessKey') and attr.has_key('secretKey') \ if ('accessKey' in attr.keys() and 'secretKey' in attr.keys() \
and attr.has_key('isAdmin')): and 'isAdmin' in attr.keys()):
return { return {
'id': attr['uid'][0], 'id': attr['uid'][0],
'name': attr['cn'][0], 'name': attr['cn'][0],