summaryrefslogtreecommitdiffstats
path: root/pykolab/auth/ldap/__init__.py
diff options
context:
space:
mode:
authorPaul Boddie <paul@boddie.org.uk>2013-12-05 17:07:24 +0100
committerPaul Boddie <paul@boddie.org.uk>2013-12-05 17:07:24 +0100
commit156f4f98a26e7d54484e3306d941eae74f8ee2ed (patch)
tree909b7638addb014568def48c9d475ed924dede0a /pykolab/auth/ldap/__init__.py
parenteba809e029f8637307bc6eef1335f32778defc14 (diff)
downloadpykolab-156f4f98a26e7d54484e3306d941eae74f8ee2ed.tar.gz
Changed various expression forms to more idiomatic ones, simplifying if appropriate.
Diffstat (limited to 'pykolab/auth/ldap/__init__.py')
-rw-r--r--pykolab/auth/ldap/__init__.py232
1 files changed, 116 insertions, 116 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index e778bad..04e9982 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -115,7 +115,7 @@ class LDAP(pykolab.base.Base):
self.ldap = None
self.bind = False
- if domain == None:
+ if domain is None:
self.domain = conf.get('kolab', 'primary_domain')
else:
self.domain = domain
@@ -160,11 +160,11 @@ class LDAP(pykolab.base.Base):
except:
pass
- if base_dn == None:
+ if base_dn is None:
config_base_dn = self.config_get('base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
base_dn = ldap_base_dn
else:
base_dn = config_base_dn
@@ -194,7 +194,7 @@ class LDAP(pykolab.base.Base):
except:
pass
- if entry_dn == None:
+ if entry_dn is None:
_search = self.ldap.search_ext(
base_dn,
ldap.SCOPE_SUBTREE,
@@ -261,7 +261,7 @@ class LDAP(pykolab.base.Base):
"""
Connect to the LDAP server through the uri configured.
"""
- if not self.ldap == None:
+ if self.ldap is not None:
return
log.debug(_("Connecting to LDAP..."), level=8)
@@ -388,7 +388,7 @@ class LDAP(pykolab.base.Base):
self._bind()
- if not exclude_entry_id == None:
+ if exclude_entry_id is not None:
__filter_prefix = "(&"
__filter_suffix = "(!(%s=%s)))" % (
self.config_get('unique_attribute'),
@@ -430,7 +430,7 @@ class LDAP(pykolab.base.Base):
config_base_dn = self.config_get('base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
base_dn = ldap_base_dn
else:
base_dn = config_base_dn
@@ -449,7 +449,7 @@ class LDAP(pykolab.base.Base):
(_entry_id, _entry_attrs) = _result
# Prevent Active Directory referrals
- if not _entry_id == None:
+ if _entry_id is not None:
_entry_dns.append(_entry_id)
return _entry_dns
@@ -464,7 +464,7 @@ class LDAP(pykolab.base.Base):
self._bind()
- if not exclude_entry_id == None:
+ if exclude_entry_id is not None:
__filter_prefix = "(&"
__filter_suffix = "(!(%s=%s)))" % (
self.config_get('unique_attribute'),
@@ -476,7 +476,7 @@ class LDAP(pykolab.base.Base):
__filter_suffix = ""
resource_filter = self.config_get('resource_filter')
- if not resource_filter == None:
+ if resource_filter is not None:
__filter_prefix = "(&%s" % resource_filter
__filter_suffix = ")"
@@ -506,7 +506,7 @@ class LDAP(pykolab.base.Base):
config_base_dn = self.config_get('resource_base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
resource_base_dn = ldap_base_dn
else:
resource_base_dn = config_base_dn
@@ -536,7 +536,7 @@ class LDAP(pykolab.base.Base):
"""
List alias domain name spaces for the current domain name space.
"""
- if not self.domains == None:
+ if self.domains is not None:
return [s for s in self.domains.keys() if not s in self.domains.values()]
else:
return []
@@ -572,12 +572,12 @@ class LDAP(pykolab.base.Base):
# 'alias' and 'mailalternateaddress' are considered for secondary mail.
#
primary_mail = self.config_get_raw('%s_primary_mail' % (entry_type))
- if primary_mail == None and entry_type == 'user':
+ if primary_mail is None and entry_type == 'user':
primary_mail = self.config_get_raw('primary_mail')
- if not secondary_mail_attribute == None:
+ if secondary_mail_attribute is not None:
secondary_mail = self.config_get_raw('%s_secondary_mail' % (entry_type))
- if secondary_mail == None and entry_type == 'user':
+ if secondary_mail is None and entry_type == 'user':
secondary_mail = self.config_get_raw('secondary_mail')
log.debug(
@@ -595,16 +595,16 @@ class LDAP(pykolab.base.Base):
log.debug(_("key %r not in entry") % (_mail_attr), level=8)
if _mail_attr == primary_mail_attribute:
log.debug(_("key %r is the prim. mail attr.") % (_mail_attr), level=8)
- if not primary_mail == None:
+ if primary_mail is not None:
log.debug(_("prim. mail pol. is not empty"), level=8)
want_attrs.append(_mail_attr)
elif _mail_attr == secondary_mail_attribute:
log.debug(_("key %r is the sec. mail attr.") % (_mail_attr), level=8)
- if not secondary_mail == None:
+ if secondary_mail is not None:
log.debug(_("sec. mail pol. is not empty"), level=8)
want_attrs.append(_mail_attr)
- if len(want_attrs) > 0:
+ if want_attrs:
log.debug(_("Attributes %r are not yet available for entry %r") % (
want_attrs,
entry_dn
@@ -618,7 +618,7 @@ class LDAP(pykolab.base.Base):
want_attrs.append('preferredlanguage')
# If we wanted anything, now is the time to get it.
- if len(want_attrs) > 0:
+ if want_attrs:
log.debug(_("Attributes %r are not yet available for entry %r") % (
want_attrs,
entry_dn
@@ -634,7 +634,7 @@ class LDAP(pykolab.base.Base):
entry['preferredlanguage'] = conf.get('kolab', 'default_locale')
# Primary mail address
- if not primary_mail == None:
+ if primary_mail is not None:
primary_mail_address = conf.plugins.exec_hook(
"set_primary_mail",
kw={
@@ -644,7 +644,7 @@ class LDAP(pykolab.base.Base):
}
)
- if primary_mail_address == None:
+ if primary_mail_address is None:
return entry_modifications
i = 1
@@ -656,7 +656,7 @@ class LDAP(pykolab.base.Base):
# Length of results should be 0 (no entry found)
# or 1 (which should be the entry we're looking at here)
- if len(results) == 0:
+ if not results:
log.debug(
_("No results for mail address %s found") % (
_primary_mail
@@ -677,7 +677,7 @@ class LDAP(pykolab.base.Base):
almost_done = True
for result in results:
- if not result == entry_dn:
+ if result != entry_dn:
log.debug(
_("Too bad, primary email address %s " + \
"already in use for %s (we are %s)") % (
@@ -708,17 +708,17 @@ class LDAP(pykolab.base.Base):
###
### FIXME
###
- if not primary_mail_address == None:
+ if primary_mail_address is not None:
if not entry.has_key(primary_mail_attribute):
self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address)
entry_modifications[primary_mail_attribute] = primary_mail_address
else:
- if not primary_mail_address == entry[primary_mail_attribute]:
+ if primary_mail_address != entry[primary_mail_attribute]:
self.set_entry_attribute(entry, primary_mail_attribute, primary_mail_address)
entry_modifications[primary_mail_attribute] = primary_mail_address
- if not secondary_mail == None:
+ if secondary_mail is not None:
# Execute the plugin hook
suggested_secondary_mail = conf.plugins.exec_hook(
"set_secondary_mail",
@@ -743,7 +743,7 @@ class LDAP(pykolab.base.Base):
# Length of results should be 0 (no entry found)
# or 1 (which should be the entry we're looking at here)
- if len(results) == 0:
+ if not results:
log.debug(
_("No results for address %s found") % (
__secondary_mail
@@ -765,7 +765,7 @@ class LDAP(pykolab.base.Base):
almost_done = True
for result in results:
- if not result == entry_dn:
+ if result != entry_dn:
log.debug(
_("Too bad, secondary email " + \
"address %s already in use for " + \
@@ -803,7 +803,7 @@ class LDAP(pykolab.base.Base):
else:
secondary_mail_addresses.append(entry[secondary_mail_attribute])
- if not secondary_mail_addresses == None:
+ if secondary_mail_addresses is not None:
log.debug(
_("Secondary mail addresses that we want is not None: %r") % (
secondary_mail_addresses
@@ -840,7 +840,7 @@ class LDAP(pykolab.base.Base):
level=9
)
- if not len(secondary_mail_addresses) == 0:
+ if secondary_mail_addresses:
self.set_entry_attribute(
entry,
secondary_mail_attribute,
@@ -861,7 +861,7 @@ class LDAP(pykolab.base.Base):
log.debug(_("secondary_mail_addresses: %r") % (secondary_mail_addresses), level=8)
log.debug(_("entry[%s]: %r") % (secondary_mail_attribute,entry[secondary_mail_attribute]), level=8)
- if not list(set(secondary_mail_addresses)) == list(set(entry[secondary_mail_attribute])):
+ if list(set(secondary_mail_addresses)) != list(set(entry[secondary_mail_attribute])):
self.set_entry_attribute(
entry,
secondary_mail_attribute,
@@ -882,7 +882,7 @@ class LDAP(pykolab.base.Base):
config_base_dn = self.config_get('base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
base_dn = ldap_base_dn
else:
base_dn = config_base_dn
@@ -920,17 +920,17 @@ class LDAP(pykolab.base.Base):
entry[attribute] = self.get_entry_attribute(entry_id, attribute)
for attribute in attrs.keys():
- if entry.has_key(attribute) and entry[attribute] == None:
+ if entry.has_key(attribute) and entry[attribute] is None:
modlist.append((ldap.MOD_ADD, attribute, attrs[attribute]))
- elif entry.has_key(attribute) and not entry[attribute] == None:
- if attrs[attribute] == None:
+ elif entry.has_key(attribute) and entry[attribute] is not None:
+ if attrs[attribute] is None:
modlist.append((ldap.MOD_DELETE, attribute, entry[attribute]))
else:
modlist.append((ldap.MOD_REPLACE, attribute, attrs[attribute]))
dn = entry_dn
- if len(modlist) > 0:
+ if modlist:
try:
self.ldap.modify_s(dn, modlist)
except:
@@ -949,7 +949,7 @@ class LDAP(pykolab.base.Base):
log.debug(_("Using filter %r") % (_filter), level=8)
- if not mode == 0:
+ if mode != 0:
override_search = mode
else:
override_search = False
@@ -957,7 +957,7 @@ class LDAP(pykolab.base.Base):
config_base_dn = self.config_get('base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
base_dn = ldap_base_dn
else:
base_dn = config_base_dn
@@ -987,11 +987,11 @@ class LDAP(pykolab.base.Base):
default_quota = self.config_get('default_quota')
quota_attribute = self.config_get('quota_attribute')
- if quota_attribute == None:
+ if quota_attribute is None:
return
# The default quota may be None, but LDAP quota could still be set
- if default_quota == None:
+ if default_quota is None:
default_quota = 0
self._bind()
@@ -1001,7 +1001,7 @@ class LDAP(pykolab.base.Base):
current_ldap_quota = self.get_entry_attribute(entry_dn, quota_attribute)
_imap_quota = self.imap.get_quota(folder)
- if _imap_quota == None:
+ if _imap_quota is None:
used = None
current_imap_quota = None
else:
@@ -1028,31 +1028,31 @@ class LDAP(pykolab.base.Base):
)
try:
- current_ldap_quota = (int)(current_ldap_quota)
+ current_ldap_quota = int(current_ldap_quota)
except:
current_ldap_quota = None
- if not current_ldap_quota == None:
- if not new_quota == (int)(current_ldap_quota):
+ if current_ldap_quota is not None:
+ if new_quota != int(current_ldap_quota):
self.set_entry_attribute(
entry_dn,
quota_attribute,
"%s" % (new_quota)
)
else:
- if not new_quota == None:
+ if new_quota is not None:
self.set_entry_attribute(
entry_dn,
quota_attribute,
"%s" % (new_quota)
)
- if not current_imap_quota == None:
- if not new_quota == current_imap_quota:
+ if current_imap_quota is not None:
+ if new_quota != current_imap_quota:
self.imap.set_quota(folder, new_quota)
else:
- if not new_quota == None:
+ if new_quota is not None:
self.imap.set_quota(folder, new_quota)
###
@@ -1060,7 +1060,7 @@ class LDAP(pykolab.base.Base):
###
def _bind(self):
- if self.ldap == None:
+ if self.ldap is None:
self.connect()
if not self.bind:
@@ -1128,14 +1128,14 @@ class LDAP(pykolab.base.Base):
server = entry[mailserver_attribute]
foldertype_attribute = self.config_get('sharedfolder_type_attribute')
- if not foldertype_attribute == None:
+ if foldertype_attribute is not None:
if not entry.has_key(foldertype_attribute):
entry[foldertype_attribute] = self.get_user_attribute(
entry['id'],
foldertype_attribute
)
- if not entry[foldertype_attribute] == None:
+ if entry[foldertype_attribute] is not None:
entry['kolabfoldertype'] = entry[foldertype_attribute]
if not entry.has_key('kolabfoldertype'):
@@ -1146,14 +1146,14 @@ class LDAP(pykolab.base.Base):
# A delivery address is postuser+targetfolder
delivery_address_attribute = self.config_get('sharedfolder_delivery_address_attribute')
- if not delivery_address_attribute == None:
+ if delivery_address_attribute is not None:
if not entry.has_key(delivery_address_attribute):
entry[delivery_address_attribute] = self.get_entry_attribute(
entry['id'],
delivery_address_attribute
)
- if not entry[delivery_address_attribute] == None:
+ if entry[delivery_address_attribute] is not None:
if len(entry[delivery_address_attribute].split('+')) > 1:
entry['kolabtargetfolder'] = entry[delivery_address_attribute].split('+')[1]
@@ -1164,7 +1164,7 @@ class LDAP(pykolab.base.Base):
)
if entry.has_key('kolabtargetfolder') and \
- not entry['kolabtargetfolder'] == None:
+ entry['kolabtargetfolder'] is not None:
folder_path = entry['kolabtargetfolder']
else:
@@ -1181,14 +1181,14 @@ class LDAP(pykolab.base.Base):
folderacl_entry_attribute = self.config_get('sharedfolder_acl_entry_attribute')
- if not folderacl_entry_attribute == None:
+ if folderacl_entry_attribute is not None:
if not entry.has_key(folderacl_entry_attribute):
entry[folderacl_entry_attribute] = self.get_entry_attribute(
entry['id'],
folderacl_entry_attribute
)
- if not entry[folderacl_entry_attribute] == None:
+ if entry[folderacl_entry_attribute] is not None:
# Parse it before assigning it
entry['kolabmailfolderaclentry'] = []
if not isinstance(entry[folderacl_entry_attribute], list):
@@ -1225,7 +1225,7 @@ class LDAP(pykolab.base.Base):
self.imap.shared_folder_create(folder_path, server)
if entry.has_key('kolabfoldertype') and \
- not entry['kolabfoldertype'] == None:
+ entry['kolabfoldertype'] is not None:
self.imap.shared_folder_set_type(
folder_path,
@@ -1233,17 +1233,17 @@ class LDAP(pykolab.base.Base):
)
if entry.has_key(delivery_address_attribute) and \
- not entry[delivery_address_attribute] == None:
+ entry[delivery_address_attribute] is not None:
self.imap.set_acl(folder_path, 'anyone', 'p')
if entry.has_key('kolabmailfolderaclentry') and \
- not entry['kolabmailfolderaclentry'] == None:
+ entry['kolabmailfolderaclentry'] is not None:
self.imap._set_kolab_mailfolder_acls(
entry['kolabmailfolderaclentry']
)
- #if server == None:
+ #if server is None:
#self.entry_set_attribute(mailserver_attribute, server)
def _change_add_unknown(self, entry, change):
@@ -1256,7 +1256,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return None
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return None
for _type in ['user','group','role','sharedfolder']:
@@ -1274,7 +1274,7 @@ class LDAP(pykolab.base.Base):
An entry of type user was added.
"""
mailserver_attribute = self.config_get('mailserver_attribute')
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
mailserver_attribute = 'mailhost'
result_attribute = conf.get('cyrus-sasl', 'result_attribute')
@@ -1290,7 +1290,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return
if entry[result_attribute] == '':
@@ -1327,7 +1327,7 @@ class LDAP(pykolab.base.Base):
level=8
)
- if not entry[mailserver_attribute] == server:
+ if entry[mailserver_attribute] != server:
self.set_entry_attribute(entry, mailserver_attribute, server)
self.user_quota(entry, folder)
@@ -1342,7 +1342,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return None
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return None
self.imap.cleanup_acls(entry[result_attribute])
@@ -1367,7 +1367,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return None
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return None
success = True
@@ -1389,7 +1389,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return None
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return None
cache.delete_entry(self.domain, entry)
@@ -1417,7 +1417,7 @@ class LDAP(pykolab.base.Base):
old_canon_attr = None
cache_entry = cache.get_entry(self.domain, entry)
- if not cache_entry == None:
+ if cache_entry is not None:
old_canon_attr = cache_entry.result_attribute
# See if we have to trigger the recipient policy. Only really applies to
@@ -1430,11 +1430,11 @@ class LDAP(pykolab.base.Base):
if new_rdn == old_rdn:
trigger_recipient_policy = True
else:
- if not new_rdn == old_rdn:
+ if new_rdn != old_rdn:
trigger_recipient_policy = True
else:
if new_rdn == result_attribute:
- if not new_rdn == old_rdn:
+ if new_rdn != old_rdn:
trigger_recipient_policy = True
if trigger_recipient_policy:
@@ -1446,7 +1446,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(result_attribute):
return
- if entry[result_attribute] == None:
+ if entry[result_attribute] is None:
return
if entry[result_attribute] == '':
@@ -1455,12 +1455,12 @@ class LDAP(pykolab.base.Base):
# Now look at entry_changes and old_canon_attr, and see if they're
# the same value.
if entry_changes.has_key(result_attribute):
- if not old_canon_attr == None:
+ if old_canon_attr is not None:
self.imap.user_mailbox_create(
entry_changes[result_attribute]
)
- elif not entry_changes[result_attribute] == old_canon_attr:
+ elif entry_changes[result_attribute] != old_canon_attr:
self.imap.user_mailbox_rename(
old_canon_attr,
entry_changes[result_attribute]
@@ -1491,14 +1491,14 @@ class LDAP(pykolab.base.Base):
server = entry[mailserver_attribute]
foldertype_attribute = self.config_get('sharedfolder_type_attribute')
- if not foldertype_attribute == None:
+ if foldertype_attribute is not None:
if not entry.has_key(foldertype_attribute):
entry[foldertype_attribute] = self.get_user_attribute(
entry['id'],
foldertype_attribute
)
- if not entry[foldertype_attribute] == None:
+ if entry[foldertype_attribute] is not None:
entry['kolabfoldertype'] = entry[foldertype_attribute]
if not entry.has_key('kolabfoldertype'):
@@ -1509,14 +1509,14 @@ class LDAP(pykolab.base.Base):
# A delivery address is postuser+targetfolder
delivery_address_attribute = self.config_get('sharedfolder_delivery_address_attribute')
- if not delivery_address_attribute == None:
+ if delivery_address_attribute is not None:
if not entry.has_key(delivery_address_attribute):
entry[delivery_address_attribute] = self.get_entry_attribute(
entry['id'],
delivery_address_attribute
)
- if not entry[delivery_address_attribute] == None:
+ if entry[delivery_address_attribute] is not None:
if len(entry[delivery_address_attribute].split('+')) > 1:
entry['kolabtargetfolder'] = entry[delivery_address_attribute].split('+')[1]
@@ -1527,7 +1527,7 @@ class LDAP(pykolab.base.Base):
)
if entry.has_key('kolabtargetfolder') and \
- not entry['kolabtargetfolder'] == None:
+ entry['kolabtargetfolder'] is not None:
folder_path = entry['kolabtargetfolder']
else:
@@ -1544,14 +1544,14 @@ class LDAP(pykolab.base.Base):
folderacl_entry_attribute = self.config_get('sharedfolder_acl_entry_attribute')
- if not folderacl_entry_attribute == None:
+ if folderacl_entry_attribute is not None:
if not entry.has_key(folderacl_entry_attribute):
entry[folderacl_entry_attribute] = self.get_entry_attribute(
entry['id'],
folderacl_entry_attribute
)
- if not entry[folderacl_entry_attribute] == None:
+ if entry[folderacl_entry_attribute] is not None:
# Parse it before assigning it
entry['kolabmailfolderaclentry'] = []
if not isinstance(entry[folderacl_entry_attribute], list):
@@ -1588,7 +1588,7 @@ class LDAP(pykolab.base.Base):
self.imap.shared_folder_create(folder_path, server)
if entry.has_key('kolabfoldertype') and \
- not entry['kolabfoldertype'] == None:
+ entry['kolabfoldertype'] is not None:
self.imap.shared_folder_set_type(
folder_path,
@@ -1596,17 +1596,17 @@ class LDAP(pykolab.base.Base):
)
if entry.has_key(delivery_address_attribute) and \
- not entry[delivery_address_attribute] == None:
+ entry[delivery_address_attribute] is not None:
self.imap.set_acl(folder_path, 'anyone', 'p')
if entry.has_key('kolabmailfolderaclentry') and \
- not entry['kolabmailfolderaclentry'] == None:
+ entry['kolabmailfolderaclentry'] is not None:
self.imap._set_kolab_mailfolder_acls(
entry['kolabmailfolderaclentry']
)
- #if server == None:
+ #if server is None:
#self.entry_set_attribute(mailserver_attribute, server)
def _change_modify_user(self, entry, change):
@@ -1624,8 +1624,8 @@ class LDAP(pykolab.base.Base):
_entry = cache.get_entry(self.domain, entry, update=False)
# We do not necessarily have a synchronisation cache entry (#1701)
- if not _entry == None:
- if _entry.__dict__.has_key('result_attribute') and not _entry.result_attribute == '':
+ if _entry is not None:
+ if _entry.__dict__.has_key('result_attribute') and _entry.result_attribute:
old_canon_attr = _entry.result_attribute
entry_changes = self.recipient_policy(entry)
@@ -1636,7 +1636,7 @@ class LDAP(pykolab.base.Base):
)
if entry_changes.has_key(result_attribute):
- if not entry_changes[result_attribute] == old_canon_attr:
+ if entry_changes[result_attribute] != old_canon_attr:
self.imap.user_mailbox_rename(
old_canon_attr,
entry_changes[result_attribute]
@@ -1645,7 +1645,7 @@ class LDAP(pykolab.base.Base):
entry[result_attribute] = entry_changes[result_attribute]
cache.get_entry(self.domain, entry)
elif entry.has_key(result_attribute):
- if not entry[result_attribute] == old_canon_attr:
+ if entry[result_attribute] != old_canon_attr:
self.imap.user_mailbox_rename(
old_canon_attr,
entry[result_attribute]
@@ -1717,7 +1717,7 @@ class LDAP(pykolab.base.Base):
#)
if entry.has_key('kolabtargetfolder') and \
- not entry['kolabtargetfolder'] == None:
+ entry['kolabtargetfolder'] is not None:
folder_path = entry['kolabtargetfolder']
else:
@@ -1736,7 +1736,7 @@ class LDAP(pykolab.base.Base):
self.imap.shared_folder_create(folder_path, server)
if entry.has_key('kolabfoldertype') and \
- not entry['kolabfoldertype'] == None:
+ entry['kolabfoldertype'] is not None:
self.imap.shared_folder_set_type(
folder_path,
@@ -1744,13 +1744,13 @@ class LDAP(pykolab.base.Base):
)
#if entry.has_key('kolabmailfolderaclentry') and \
- #not entry['kolabmailfolderaclentry'] == None:
+ #entry['kolabmailfolderaclentry'] is not None:
#self.imap._set_kolab_mailfolder_acls(
#entry['kolabmailfolderaclentry']
#)
- #if server == None:
+ #if server is None:
#self.entry_set_attribute(mailserver_attribute, server)
def _change_none_user(self, entry, change):
@@ -1763,13 +1763,13 @@ class LDAP(pykolab.base.Base):
_entry = cache.get_entry(self.domain, entry, update=False)
- if not _entry == None and _entry.__dict__.has_key('result_attribute') and not _entry.result_attribute == '':
+ if _entry is not None and _entry.__dict__.has_key('result_attribute') and _entry.result_attribute:
old_canon_attr = _entry.result_attribute
entry_changes = self.recipient_policy(entry)
if entry.has_key(result_attribute) and entry_changes.has_key(result_attribute):
- if not entry[result_attribute] == entry_changes[result_attribute]:
+ if entry[result_attribute] != entry_changes[result_attribute]:
old_canon_attr = entry[result_attribute]
log.debug(
@@ -1777,8 +1777,8 @@ class LDAP(pykolab.base.Base):
level=8
)
- if entry_changes.has_key(result_attribute) and not old_canon_attr == None:
- if not entry_changes[result_attribute] == old_canon_attr:
+ if entry_changes.has_key(result_attribute) and old_canon_attr is not None:
+ if entry_changes[result_attribute] != old_canon_attr:
self.imap.user_mailbox_rename(
old_canon_attr,
entry_changes[result_attribute]
@@ -1793,7 +1793,7 @@ class LDAP(pykolab.base.Base):
self.imap.connect(domain=self.domain)
if entry.has_key(result_attribute) and \
- not entry.has_key(result_attribute) == None:
+ entry.has_key(result_attribute) is not None:
if not self.imap.user_mailbox_exists(entry[result_attribute]):
folder = self.imap.user_mailbox_create(entry[result_attribute])
@@ -1812,7 +1812,7 @@ class LDAP(pykolab.base.Base):
if not entry.has_key(mailserver_attr):
self.set_entry_attribute(entry, mailserver_attr, server)
else:
- if not entry[mailserver_attr] == server:
+ if entry[mailserver_attr] != server:
# TODO: Should actually transfer mailbox
self.set_entry_attribute(entry, mailserver_attr, server)
@@ -1874,17 +1874,17 @@ class LDAP(pykolab.base.Base):
config_base_dn = self.config_get('base_dn')
ldap_base_dn = self._kolab_domain_root_dn(self.domain)
- if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ if ldap_base_dn is not None and ldap_base_dn != config_base_dn:
base_dn = ldap_base_dn
else:
base_dn = config_base_dn
for _type in ['user', 'group', 'sharedfolder']:
__filter = self.config_get('kolab_%s_filter' % (_type))
- if __filter == None:
+ if __filter is None:
__filter = self.config_get('%s_filter' % (_type))
- if not __filter == None:
+ if __filter is not None:
try:
result = self._regular_search(entry_dn, filterstr=__filter)
except:
@@ -1908,7 +1908,7 @@ class LDAP(pykolab.base.Base):
domain_root_dn = self._kolab_domain_root_dn(self.domain)
base_dn = self.config_get('user_base_dn')
- if base_dn == None:
+ if base_dn is None:
base_dn = self.config_get('base_dn')
auth_attrs = self.config_get_list('auth_attributes')
@@ -1980,7 +1980,7 @@ class LDAP(pykolab.base.Base):
domain_base_dn = conf.get('ldap', 'domain_base_dn', quiet=True)
- if not domain_base_dn == "":
+ if domain_base_dn:
# If we haven't returned already, let's continue searching
domain_name_attribute = conf.get('ldap', 'domain_name_attribute')
@@ -2022,10 +2022,10 @@ class LDAP(pykolab.base.Base):
_filter = "(|"
for _type in ['user', 'group', 'resource', 'sharedfolder']:
__filter = self.config_get('kolab_%s_filter' % (_type))
- if __filter == None:
+ if __filter is None:
__filter = self.config_get('%s_filter' % (_type))
- if not __filter == None:
+ if __filter is not None:
_filter = "%s%s" % (_filter,__filter)
_filter = "%s)" % (_filter)
@@ -2060,10 +2060,10 @@ class LDAP(pykolab.base.Base):
# If we haven't returned already, let's continue searching
domain_filter = conf.get('ldap', 'domain_filter')
- if not domain == None:
+ if domain is not None:
domain_filter = domain_filter.replace('*', domain)
- if domain_base_dn == None or domain_filter == None:
+ if domain_base_dn is None or domain_filter is None:
return []
# TODO: this function should be wrapped for error handling
@@ -2073,7 +2073,7 @@ class LDAP(pykolab.base.Base):
raise AuthBackendError, _("Authentication database DOWN")
dna = self.config_get('domain_name_attribute')
- if dna == None:
+ if dna is None:
dna = 'associateddomain'
try:
@@ -2156,7 +2156,7 @@ class LDAP(pykolab.base.Base):
log.debug(_("Entry type: %s") % (entry['type']), level=8)
- if change_dict['change_type'] == None:
+ if change_dict['change_type'] is None:
# This entry was in the start result set
eval("self._change_none_%s(entry, change_dict)" % (entry['type']))
else:
@@ -2186,7 +2186,7 @@ class LDAP(pykolab.base.Base):
elif kw.has_key('entry') and isinstance(kw['entry'], list):
for entry_dn,entry_attrs in kw['entry']:
# This is a referral
- if entry_dn == None:
+ if entry_dn is None:
continue
entry = { 'dn': entry_dn }
@@ -2509,10 +2509,10 @@ class LDAP(pykolab.base.Base):
_results = []
_result_type = None
- while not _result_type == ldap.RES_SEARCH_RESULT:
+ while _result_type != ldap.RES_SEARCH_RESULT:
(_result_type, _result) = self.ldap.result(_search, False, 0)
- if not _result == None:
+ if _result is not None:
for result in _result:
_results.append(result)
@@ -2539,13 +2539,13 @@ class LDAP(pykolab.base.Base):
supported_controls = conf.get_list('ldap', 'supported_controls')
- if not supported_controls == None and not len(supported_controls) < 1:
- for control_num in [(int)(x) for x in supported_controls]:
+ if supported_controls:
+ for control_num in [int(x) for x in supported_controls]:
self.ldap.supported_controls.append(
SUPPORTED_LDAP_CONTROLS[control_num]['func']
)
- if len(self.ldap.supported_controls) < 1:
+ if not self.ldap.supported_controls:
for control_num in SUPPORTED_LDAP_CONTROLS.keys():
log.debug(
_("Checking for support for %s on %s") % (
@@ -2579,7 +2579,7 @@ class LDAP(pykolab.base.Base):
_results = []
- if not override_search == False:
+ if override_search:
_use_ldap_controls = [ override_search ]
else:
_use_ldap_controls = self.ldap.supported_controls