summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorChristoph Erhardt <kolab@sicherha.de>2021-06-05 11:51:27 +0200
committerChristoph Erhardt <kolab@sicherha.de>2022-01-10 20:50:41 +0100
commit9a5f92139d3fbe7fa1945d38198a9cdc74831ac5 (patch)
tree03fff0f479a90dfaa70c6647dd0923086560dcca /pykolab
parentc3b9d5557161f840a8f2c45fc91ec09299593dd9 (diff)
downloadpykolab-9a5f92139d3fbe7fa1945d38198a9cdc74831ac5.tar.gz
[Python 3] Get rid of .has_key()
Summary: `dict.has_key(key)` was dropped in Python 3.0. Use `key in dict` instead. Reviewers: machniak, mollekopf Reviewed By: mollekopf Differential Revision: https://git.kolab.org/D3241
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/syncrepl.py2
-rw-r--r--pykolab/cli/__init__.py6
-rw-r--r--pykolab/cli/cmd_add_alias.py4
-rw-r--r--pykolab/cli/cmd_list_mailbox_metadata.py2
-rw-r--r--pykolab/cli/cmd_sync.py2
-rw-r--r--pykolab/cli/commands.py16
-rw-r--r--pykolab/cli/sieve/cmd_refresh.py22
-rw-r--r--pykolab/imap/cyrus.py6
-rw-r--r--pykolab/plugins/defaultfolders/__init__.py2
-rw-r--r--pykolab/plugins/dynamicquota/__init__.py2
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py10
-rw-r--r--pykolab/plugins/roundcubedb/__init__.py2
-rw-r--r--pykolab/plugins/sievemgmt/__init__.py24
-rw-r--r--pykolab/setup/__init__.py2
-rw-r--r--pykolab/setup/components.py16
-rw-r--r--pykolab/translit.py10
-rw-r--r--pykolab/wap_client/__init__.py18
-rw-r--r--pykolab/xml/attendee.py10
-rw-r--r--pykolab/xml/contact.py8
-rw-r--r--pykolab/xml/event.py24
-rw-r--r--pykolab/xml/note.py4
-rw-r--r--pykolab/xml/recurrence_rule.py10
-rw-r--r--pykolab/xml/todo.py20
-rw-r--r--pykolab/xml/utils.py20
24 files changed, 121 insertions, 121 deletions
diff --git a/pykolab/auth/ldap/syncrepl.py b/pykolab/auth/ldap/syncrepl.py
index 5b69c63..6753605 100644
--- a/pykolab/auth/ldap/syncrepl.py
+++ b/pykolab/auth/ldap/syncrepl.py
@@ -17,7 +17,7 @@ class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer):
callback = None
def __init__(self, filename, *args, **kwargs):
- if kwargs.has_key('callback'):
+ if 'callback' in kwargs:
self.callback = kwargs['callback']
del kwargs['callback']
diff --git a/pykolab/cli/__init__.py b/pykolab/cli/__init__.py
index 4843aba..46c9930 100644
--- a/pykolab/cli/__init__.py
+++ b/pykolab/cli/__init__.py
@@ -51,12 +51,12 @@ class Cli(object):
for arg in sys.argv[1:]:
arg_num += 1
if not arg.startswith('-') and len(sys.argv) >= arg_num:
- if commands.commands.has_key(sys.argv[arg_num].replace('-','_')):
+ if sys.argv[arg_num].replace('-','_') in commands.commands:
to_execute.append(sys.argv[arg_num].replace('-','_'))
- if commands.commands.has_key("%s_%s" % (
+ if "%s_%s" % (
'_'.join(to_execute),sys.argv[arg_num].replace('-','_')
- )):
+ ) in commands.commands:
to_execute.append(sys.argv[arg_num].replace('-','_'))
diff --git a/pykolab/cli/cmd_add_alias.py b/pykolab/cli/cmd_add_alias.py
index 5daffe5..16fa590 100644
--- a/pykolab/cli/cmd_add_alias.py
+++ b/pykolab/cli/cmd_add_alias.py
@@ -103,11 +103,11 @@ def execute(*args, **kw):
primary_recipient = auth.get_entry_attributes(primary_rcpt_domain, primary_recipient_dn, rcpt_attrs)
- if not primary_recipient.has_key(primary_rcpt_attr):
+ if primary_rcpt_attr not in primary_recipient:
print(_("Recipient %r is not the primary recipient for address %r") % (primary_recipient, primary_rcpt_address), file=sys.stderr)
sys.exit(1)
- if not primary_recipient.has_key(secondary_rcpt_attr):
+ if secondary_rcpt_attr not in primary_recipient:
auth.set_entry_attributes(primary_rcpt_domain, primary_recipient_dn, {secondary_rcpt_attr: [ secondary_rcpt_address ] })
else:
if isinstance(primary_recipient[secondary_rcpt_attr], basestring):
diff --git a/pykolab/cli/cmd_list_mailbox_metadata.py b/pykolab/cli/cmd_list_mailbox_metadata.py
index af96cda..27d881c 100644
--- a/pykolab/cli/cmd_list_mailbox_metadata.py
+++ b/pykolab/cli/cmd_list_mailbox_metadata.py
@@ -89,7 +89,7 @@ def execute(*args, **kw):
metadata = imap.get_metadata(folder)
- if metadata.has_key(folder):
+ if folder in metadata:
for annotation in metadata[folder]:
print(" %-49s %s" % (
annotation,
diff --git a/pykolab/cli/cmd_sync.py b/pykolab/cli/cmd_sync.py
index 7d44d02..2aaf9df 100644
--- a/pykolab/cli/cmd_sync.py
+++ b/pykolab/cli/cmd_sync.py
@@ -139,7 +139,7 @@ def _synchronize(*args, **kw):
imap.connect()
if not imap.user_mailbox_exists(entry[mailbox_attribute]):
- if entry.has_key('mailhost'):
+ if 'mailhost' in entry:
server = entry['mailhost']
else:
server = None
diff --git a/pykolab/cli/commands.py b/pykolab/cli/commands.py
index ba15202..a1e9b0c 100644
--- a/pykolab/cli/commands.py
+++ b/pykolab/cli/commands.py
@@ -81,10 +81,10 @@ def list_commands(*args, **kw):
_commands.sort()
for _command in _commands:
- if __commands[_command].has_key('group'):
+ if 'group' in __commands[_command]:
continue
- if __commands[_command].has_key('function'):
+ if 'function' in __commands[_command]:
# This is a top-level command
if not __commands[_command]['description'] == None:
print("%-25s - %s" % (_command.replace('_','-'),__commands[_command]['description']))
@@ -92,7 +92,7 @@ def list_commands(*args, **kw):
print("%-25s" % (_command.replace('_','-')))
for _command in _commands:
- if not __commands[_command].has_key('function'):
+ if 'function' not in __commands[_command]:
# This is a nested command
print("\n" + _("Command Group: %s") % (_command) + "\n")
___commands = __commands[_command].keys()
@@ -108,16 +108,16 @@ def execute(cmd_name, *args, **kw):
execute("help")
sys.exit(0)
- if not commands.has_key(cmd_name):
+ if cmd_name not in commands:
log.error(_("No such command."))
sys.exit(1)
- if not commands[cmd_name].has_key('function') and \
- not commands[cmd_name].has_key('group'):
+ if 'function' not in commands[cmd_name] and \
+ 'group' not in commands[cmd_name]:
log.error(_("No such command."))
sys.exit(1)
- if commands[cmd_name].has_key('group'):
+ if 'group' in commands[cmd_name]:
group = commands[cmd_name]['group']
command_name = commands[cmd_name]['cmd_name']
try:
@@ -163,7 +163,7 @@ def register(cmd_name, func, group=None, description=None, aliases=[]):
if isinstance(aliases, basestring):
aliases = [aliases]
- if commands.has_key(command):
+ if command in commands:
log.fatal(_("Command '%s' already registered") % (command))
sys.exit(1)
diff --git a/pykolab/cli/sieve/cmd_refresh.py b/pykolab/cli/sieve/cmd_refresh.py
index b784eac..0f93208 100644
--- a/pykolab/cli/sieve/cmd_refresh.py
+++ b/pykolab/cli/sieve/cmd_refresh.py
@@ -125,28 +125,28 @@ def execute(*args, **kw):
if not vacation_text_attr == None:
- if user.has_key(vacation_active_attr):
+ if vacation_active_attr in user:
vacation_active = utils.true_or_false(user[vacation_active_attr])
else:
vacation_active = False
- if user.has_key(vacation_text_attr):
+ if vacation_text_attr in user:
vacation_text = user[vacation_text_attr]
else:
vacation_active = False
- if user.has_key(vacation_uce_attr):
+ if vacation_uce_attr in user:
vacation_uce = utils.true_or_false(user[vacation_uce_attr])
else:
vacation_uce = False
- if user.has_key(vacation_react_domains_attr):
+ if vacation_react_domains_attr in user:
if isinstance(user[vacation_react_domains_attr], list):
vacation_react_domains = user[vacation_react_domains_attr]
else:
vacation_react_domains = [ user[vacation_react_domains_attr] ]
else:
- if user.has_key(vacation_noreact_domains_attr):
+ if vacation_noreact_domains_attr in user:
if isinstance(user[vacation_noreact_domains_attr], list):
vacation_noreact_domains = user[vacation_noreact_domains_attr]
else:
@@ -159,7 +159,7 @@ def execute(*args, **kw):
#
dtf_active_attr = conf.get('sieve', 'deliver_to_folder_active')
if not dtf_active_attr == None:
- if user.has_key(dtf_active_attr):
+ if dtf_active_attr in user:
dtf_active = utils.true_or_false(user[dtf_active_attr])
else:
dtf_active = False
@@ -172,7 +172,7 @@ def execute(*args, **kw):
if dtf_active:
dtf_folder_name_attr = conf.get('sieve', 'deliver_to_folder_attr')
if not dtf_folder_name_attr == None:
- if user.has_key(dtf_folder_name_attr):
+ if dtf_folder_name_attr in user:
dtf_folder = user[dtf_folder_name_attr]
else:
log.warning(_("Delivery to folder active, but no folder name attribute available for user %r") % (user))
@@ -204,14 +204,14 @@ def execute(*args, **kw):
forward_active_attr = conf.get('sieve', 'forward_address_active')
if not forward_active_attr == None:
- if user.has_key(forward_active_attr):
+ if forward_active_attr in user:
forward_active = utils.true_or_false(user[forward_active_attr])
else:
forward_active = False
if not forward_active == False:
forward_address_attr = conf.get('sieve', 'forward_address_attr')
- if user.has_key(forward_address_attr):
+ if forward_address_attr in user:
if isinstance(user[forward_address_attr], basestring):
forward_addresses = [ user[forward_address_attr] ]
elif isinstance(user[forward_address_attr], str):
@@ -224,14 +224,14 @@ def execute(*args, **kw):
forward_keepcopy_attr = conf.get('sieve', 'forward_keepcopy_active')
if not forward_keepcopy_attr == None:
- if user.has_key(forward_keepcopy_attr):
+ if forward_keepcopy_attr in user:
forward_keepcopy = utils.true_or_false(user[forward_keepcopy_attr])
else:
forward_keepcopy = False
forward_uce_attr = conf.get('sieve', 'forward_uce_active')
if not forward_uce_attr == None:
- if user.has_key(forward_uce_attr):
+ if forward_uce_attr in user:
forward_uce = utils.true_or_false(user[forward_uce_attr])
else:
forward_uce = False
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index 26e8f98..765b0ee 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -219,7 +219,7 @@ class Cyrus(cyruslib.CYRUS):
level=8
)
- if self.mbox.has_key(mailfolder):
+ if mailfolder in self.mbox:
log.debug(
_(
"Possibly reproducing the find " +
@@ -248,8 +248,8 @@ class Cyrus(cyruslib.CYRUS):
ann_path
)
- if annotations.has_key(mailfolder):
- if annotations[mailfolder].has_key(s_ann_path):
+ if mailfolder in annotations:
+ if s_ann_path in annotations[mailfolder]:
break
if max_tries <= num_try:
diff --git a/pykolab/plugins/defaultfolders/__init__.py b/pykolab/plugins/defaultfolders/__init__.py
index 0b6ee10..a4a59b0 100644
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -43,7 +43,7 @@ class KolabDefaultfolders(object):
user_folder - user folder
"""
- if not kw.has_key('additional_folders'):
+ if 'additional_folders' not in kw:
log.error(_("Plugin %s called without required keyword %s.") % ("defaultfolders", "additional_folders"))
return {}
diff --git a/pykolab/plugins/dynamicquota/__init__.py b/pykolab/plugins/dynamicquota/__init__.py
index c9b9b7f..51cb547 100644
--- a/pykolab/plugins/dynamicquota/__init__.py
+++ b/pykolab/plugins/dynamicquota/__init__.py
@@ -53,7 +53,7 @@ class KolabDynamicquota(object):
"""
for keyword in [ 'used', 'imap_quota', 'ldap_quota', 'default_quota' ]:
- if not kw.has_key(keyword):
+ if keyword not in kw:
log.warning(
_("No keyword %s passed to set_user_folder_quota") % (
keyword
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 94c707f..330ddfa 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -56,12 +56,12 @@ class KolabRecipientpolicy(object):
user_attrs = utils.normalize(kw['entry'])
- if not user_attrs.has_key('domain'):
+ if 'domain' not in user_attrs:
user_attrs['domain'] = kw['primary_domain']
elif not user_attrs['domain'] == kw['primary_domain']:
user_attrs['domain'] = kw['primary_domain']
- if not user_attrs.has_key('preferredlanguage'):
+ if 'preferredlanguage' not in user_attrs:
default_locale = conf.get(user_attrs['domain'], 'default_locale')
if default_locale == None:
default_locale = conf.get('kolab', 'default_locale')
@@ -77,7 +77,7 @@ class KolabRecipientpolicy(object):
return mail
except KeyError:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
- if user_attrs.has_key('mail'):
+ if 'mail' in user_attrs:
return user_attrs['mail']
else:
return None
@@ -96,12 +96,12 @@ class KolabRecipientpolicy(object):
user_attrs = utils.normalize(kw['entry'])
- if not user_attrs.has_key('domain'):
+ if 'domain' not in user_attrs:
user_attrs['domain'] = kw['primary_domain']
elif not user_attrs['domain'] == kw['primary_domain']:
user_attrs['domain'] = kw['primary_domain']
- if not user_attrs.has_key('preferredlanguage'):
+ if 'preferredlanguage' not in user_attrs:
default_locale = conf.get(user_attrs['domain'], 'default_locale')
if default_locale == None:
default_locale = conf.get(user_attrs['domain'], 'default_locale')
diff --git a/pykolab/plugins/roundcubedb/__init__.py b/pykolab/plugins/roundcubedb/__init__.py
index 40271c3..9fe7642 100644
--- a/pykolab/plugins/roundcubedb/__init__.py
+++ b/pykolab/plugins/roundcubedb/__init__.py
@@ -58,7 +58,7 @@ class KolabRoundcubedb(object):
result_attribute = conf.get('cyrus-sasl', 'result_attribute')
# execute Roundcube's bin/deluser.sh script to do the work
- if kw.has_key('user') and kw['user'].has_key(result_attribute) and os.path.exists(rcpath + 'bin/deluser.sh'):
+ if 'user' in kw and result_attribute in kw['user'] and os.path.exists(rcpath + 'bin/deluser.sh'):
proc = subprocess.Popen([ 'sudo -u apache', rcpath + 'bin/deluser.sh', kw['user'][result_attribute] ], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
procout, procerr = proc.communicate()
if proc.returncode != 0:
diff --git a/pykolab/plugins/sievemgmt/__init__.py b/pykolab/plugins/sievemgmt/__init__.py
index 6588bdb..f7e5368 100644
--- a/pykolab/plugins/sievemgmt/__init__.py
+++ b/pykolab/plugins/sievemgmt/__init__.py
@@ -47,7 +47,7 @@ class KolabSievemgmt(object):
user - the user identifier
"""
- if not len(kw) == 1 or not kw.has_key('user'):
+ if not len(kw) == 1 or 'user' not in kw:
log.error(_("Wrong number of arguments for sieve management plugin"))
return
else:
@@ -137,28 +137,28 @@ class KolabSievemgmt(object):
if not vacation_text_attr == None:
- if user.has_key(vacation_active_attr):
+ if vacation_active_attr in user:
vacation_active = utils.true_or_false(user[vacation_active_attr])
else:
vacation_active = False
- if user.has_key(vacation_text_attr):
+ if vacation_text_attr in user:
vacation_text = user[vacation_text_attr]
else:
vacation_active = False
- if user.has_key(vacation_uce_attr):
+ if vacation_uce_attr in user:
vacation_uce = utils.true_or_false(user[vacation_uce_attr])
else:
vacation_uce = False
- if user.has_key(vacation_react_domains_attr):
+ if vacation_react_domains_attr in user:
if isinstance(user[vacation_react_domains_attr], list):
vacation_react_domains = user[vacation_react_domains_attr]
else:
vacation_react_domains = [ user[vacation_react_domains_attr] ]
else:
- if user.has_key(vacation_noreact_domains_attr):
+ if vacation_noreact_domains_attr in user:
if isinstance(user[vacation_noreact_domains_attr], list):
vacation_noreact_domains = user[vacation_noreact_domains_attr]
else:
@@ -171,7 +171,7 @@ class KolabSievemgmt(object):
#
dtf_active_attr = conf.get('sieve', 'deliver_to_folder_active')
if not dtf_active_attr == None:
- if user.has_key(dtf_active_attr):
+ if dtf_active_attr in user:
dtf_active = utils.true_or_false(user[dtf_active_attr])
else:
dtf_active = False
@@ -184,7 +184,7 @@ class KolabSievemgmt(object):
if dtf_active:
dtf_folder_name_attr = conf.get('sieve', 'deliver_to_folder_attr')
if not dtf_folder_name_attr == None:
- if user.has_key(dtf_folder_name_attr):
+ if dtf_folder_name_attr in user:
dtf_folder = user[dtf_folder_name_attr]
else:
log.warning(_("Delivery to folder active, but no folder name attribute available for user %r") % (user))
@@ -216,14 +216,14 @@ class KolabSievemgmt(object):
forward_active_attr = conf.get('sieve', 'forward_address_active')
if not forward_active_attr == None:
- if user.has_key(forward_active_attr):
+ if forward_active_attr in user:
forward_active = utils.true_or_false(user[forward_active_attr])
else:
forward_active = False
if not forward_active == False:
forward_address_attr = conf.get('sieve', 'forward_address_attr')
- if user.has_key(forward_address_attr):
+ if forward_address_attr in user:
if isinstance(user[forward_address_attr], basestring):
forward_addresses = [ user[forward_address_attr] ]
elif isinstance(user[forward_address_attr], str):
@@ -236,14 +236,14 @@ class KolabSievemgmt(object):
forward_keepcopy_attr = conf.get('sieve', 'forward_keepcopy_active')
if not forward_keepcopy_attr == None:
- if user.has_key(forward_keepcopy_attr):
+ if forward_keepcopy_attr in user:
forward_keepcopy = utils.true_or_false(user[forward_keepcopy_attr])
else:
forward_keepcopy = False
forward_uce_attr = conf.get('sieve', 'forward_uce_active')
if not forward_uce_attr == None:
- if user.has_key(forward_uce_attr):
+ if forward_uce_attr in user:
forward_uce = utils.true_or_false(user[forward_uce_attr])
else:
forward_uce = False
diff --git a/pykolab/setup/__init__.py b/pykolab/setup/__init__.py
index 52bee91..26638b0 100644
--- a/pykolab/setup/__init__.py
+++ b/pykolab/setup/__init__.py
@@ -37,7 +37,7 @@ class Setup(object):
for arg in sys.argv[1:]:
arg_num += 1
if not arg.startswith('-') and len(sys.argv) >= arg_num:
- if components.components.has_key(sys.argv[arg_num].replace('-','_')):
+ if sys.argv[arg_num].replace('-','_') in components.components:
to_execute.append(sys.argv[arg_num].replace('-','_'))
def run(self):
diff --git a/pykolab/setup/components.py b/pykolab/setup/components.py
index f68bb48..49a4f65 100644
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -77,7 +77,7 @@ def list_components(*args, **kw):
_components.sort()
for _component in _components:
- if __components[_component].has_key('function'):
+ if 'function' in __components[_component]:
# This is a top-level component
if not __components[_component]['description'] == None:
print("%-25s - %s" % (_component.replace('_','-'),__components[_component]['description']))
@@ -85,7 +85,7 @@ def list_components(*args, **kw):
print("%-25s" % (_component.replace('_','-')))
for _component in _components:
- if not __components[_component].has_key('function'):
+ if 'function' not in __components[_component]:
# This is a nested component
print("\n" + _("Command Group: %s") % (_component) + "\n")
___components = __components[_component].keys()
@@ -124,7 +124,7 @@ def cli_options_from_component(component_name, *args, **kw):
if component_name in components_included_in_cli:
return
- if components[component_name].has_key('group'):
+ if 'group' in components[component_name]:
group = components[component_name]['group']
component_name = components[component_name]['component_name']
try:
@@ -161,7 +161,7 @@ def execute(component_name, *args, **kw):
execute_this = False
if execute_this:
- if components[component].has_key('after'):
+ if 'after' in components[component]:
for _component in components[component]['after']:
if not _component in executed_components:
execute_this = False
@@ -183,12 +183,12 @@ def execute(component_name, *args, **kw):
for component in _list_components():
cli_options_from_component(component)
- if not components.has_key(component_name):
+ if component_name not in components:
log.error(_("No such component."))
sys.exit(1)
- if not components[component_name].has_key('function') and \
- not components[component_name].has_key('group'):
+ if 'function' not in components[component_name] and \
+ 'group' not in components[component_name]:
log.error(_("No such component."))
sys.exit(1)
@@ -227,7 +227,7 @@ def register(component_name, func, group=None, description=None, aliases=[], aft
if isinstance(aliases, basestring):
aliases = [aliases]
- if components.has_key(component):
+ if component in components:
log.fatal(_("Command '%s' already registered") % (component))
sys.exit(1)
diff --git a/pykolab/translit.py b/pykolab/translit.py
index cf54bae..d1c0459 100644
--- a/pykolab/translit.py
+++ b/pykolab/translit.py
@@ -98,7 +98,7 @@ translit_map = {
}
def transliterate(_input, lang, _output_expected=None):
- if locale_translit_map.has_key(lang):
+ if lang in locale_translit_map:
_translit_name = locale_translit_map[lang]
else:
_translit_name = lang
@@ -107,8 +107,8 @@ def transliterate(_input, lang, _output_expected=None):
if not isinstance(_input, unicode):
for char in _input.decode('utf-8'):
- if translit_map.has_key(_translit_name):
- if translit_map[_translit_name].has_key(char):
+ if _translit_name in translit_map:
+ if char in translit_map[_translit_name]:
_output += translit_map[_translit_name][char]
elif char in [repr(x) for x in translit_map[_translit_name]]:
_output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name]]][0]]
@@ -118,8 +118,8 @@ def transliterate(_input, lang, _output_expected=None):
_output += char
else:
for char in _input:
- if translit_map.has_key(_translit_name):
- if translit_map[_translit_name].has_key(char):
+ if _translit_name in translit_map:
+ if char in translit_map[_translit_name]:
_output += translit_map[_translit_name][char]
elif char in [repr(x) for x in translit_map[_translit_name]]:
_output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name]]][0]]
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 034be05..bfb2e2c 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -70,7 +70,7 @@ def authenticate(username=None, password=None, domain=None):
if not response:
return False
- if response.has_key('session_token'):
+ if 'session_token' in response:
session_id = response['session_token']
return True
@@ -203,7 +203,7 @@ def get_group_input():
print("No group types available")
sys.exit(1)
- if group_types.has_key(group_type_id):
+ if group_type_id in group_types:
group_type_info = group_types[group_type_id]['attributes']
else:
print("No such group type")
@@ -242,7 +242,7 @@ def get_user_input():
print("No user types available")
sys.exit(1)
- if user_types['list'].has_key(user_type_id):
+ if user_type_id in user_types['list']:
user_type_info = user_types['list'][user_type_id]['attributes']
else:
print("No such user type")
@@ -258,7 +258,7 @@ def get_user_input():
for attribute in user_type_info['form_fields']:
if isinstance(user_type_info['form_fields'][attribute], dict):
- if user_type_info['form_fields'][attribute].has_key('optional') and user_type_info['form_fields'][attribute]['optional']:
+ if 'optional' in user_type_info['form_fields'][attribute] and user_type_info['form_fields'][attribute]['optional']:
may_attrs.append(attribute)
else:
must_attrs.append(attribute)
@@ -267,14 +267,14 @@ def get_user_input():
for attribute in must_attrs:
if isinstance(user_type_info['form_fields'][attribute], dict) and \
- user_type_info['form_fields'][attribute].has_key('type'):
+ 'type' in user_type_info['form_fields'][attribute]:
if user_type_info['form_fields'][attribute]['type'] == 'select':
- if not user_type_info['form_fields'][attribute].has_key('values'):
+ if 'values' not in user_type_info['form_fields'][attribute]:
attribute_values = form_value_select_options('user', user_type_id, attribute)
default = ''
- if attribute_values[attribute].has_key('default'):
+ if 'default' in attribute_values[attribute]:
default = attribute_values[attribute]['default']
params[attribute] = utils.ask_menu(
@@ -285,7 +285,7 @@ def get_user_input():
else:
default = ''
- if user_type_info['form_fields'][attribute].has_key('default'):
+ if 'default' in user_type_info['form_fields'][attribute]:
default = user_type_info['form_fields'][attribute]['default']
params[attribute] = utils.ask_menu(
@@ -497,7 +497,7 @@ def role_delete(params=None):
'role': role.keys()[0]
}
- if not params.has_key('role'):
+ if 'role' not in params:
role = role_find_by_attribute(params)
params = {
'role': role.keys()[0]
diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py
index b7be74b..f82f96e 100644
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -25,7 +25,7 @@ participant_status_labels = {
}
def participant_status_label(status):
- return _(participant_status_labels[status]) if participant_status_labels.has_key(status) else _(status)
+ return _(participant_status_labels[status]) if status in participant_status_labels else _(status)
class Attendee(kolabformat.Attendee):
@@ -92,7 +92,7 @@ class Attendee(kolabformat.Attendee):
if isinstance(rsvp, bool):
self.setRSVP(rsvp)
else:
- if self.rsvp_map.has_key(rsvp):
+ if rsvp in self.rsvp_map:
self.setRSVP(self.rsvp_map[rsvp])
if not role == None:
@@ -101,10 +101,10 @@ class Attendee(kolabformat.Attendee):
if not cutype == None:
self.set_cutype(cutype)
- if ical_params and ical_params.has_key('DELEGATED-FROM'):
+ if ical_params and 'DELEGATED-FROM' in ical_params:
self.delegate_from(Attendee(str(ical_params['DELEGATED-FROM']), role=self.get_role(), cutype=self.get_cutype()))
- if ical_params and ical_params.has_key('DELEGATED-TO'):
+ if ical_params and 'DELEGATED-TO' in ical_params:
self.delegate_to(Attendee(str(ical_params['DELEGATED-TO'])))
if not participant_status == None:
@@ -211,7 +211,7 @@ class Attendee(kolabformat.Attendee):
def _translate_value(self, val, map):
name_map = dict([(v, k) for (k, v) in map.iteritems()])
- return name_map[val] if name_map.has_key(val) else 'UNKNOWN'
+ return name_map[val] if val in name_map else 'UNKNOWN'
def set_cutype(self, cutype):
if cutype in self.cutype_map:
diff --git a/pykolab/xml/contact.py b/pykolab/xml/contact.py
index f4fd9a5..f5053e6 100644
--- a/pykolab/xml/contact.py
+++ b/pykolab/xml/contact.py
@@ -23,7 +23,7 @@ def contact_from_message(message):
contact = contact_from_string(payload)
# append attachment parts to Contact object
- elif contact and part.has_key('Content-ID'):
+ elif contact and 'Content-ID' in part:
contact._attachment_parts.append(part)
return contact
@@ -161,7 +161,7 @@ class Contact(kolabformat.Contact):
def _translate_value(self, val, map):
name_map = dict([(v, k) for (k, v) in map.iteritems()])
- return name_map[val] if name_map.has_key(val) else 'UNKNOWN'
+ return name_map[val] if val in name_map else 'UNKNOWN'
def to_dict(self):
if not self.isValid():
@@ -198,7 +198,7 @@ class Contact(kolabformat.Contact):
affiliations = self.affiliations()
if len(affiliations) > 0:
_affiliation = self._affiliation2dict(affiliations[0])
- if _affiliation.has_key('address'):
+ if 'address' in _affiliation:
data['address'].extend(_affiliation['address'])
_affiliation.pop('address', None)
data.update(_affiliation)
@@ -299,7 +299,7 @@ class Contact(kolabformat.Contact):
val = rel.uri() if rel.type() == kolabformat.Related.Uid else rel.text()
if reltype and val is not None:
if aslist:
- if not data.has_key(reltype):
+ if reltype not in data:
data[reltype] = []
data[reltype].append(val)
else:
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index d85b621..e957a19 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -39,7 +39,7 @@ def event_from_message(message):
event = event_from_string(payload)
# append attachment parts to Event object
- elif event and part.has_key('Content-ID'):
+ elif event and 'Content-ID' in part:
event._attachment_parts.append(part)
return event
@@ -353,7 +353,7 @@ class Event(object):
break
# use the libkolab calendaring bindings to load the full iCal data
- if ical_event.has_key('RRULE') or ical_event.has_key('ATTACH') \
+ if 'RRULE' in ical_event or 'ATTACH' in ical_event \
or [part for part in ical_event.walk() if part.name == 'VALARM']:
if raw is None or raw == "":
raw = ical if isinstance(ical, str) else ical.to_ical()
@@ -364,20 +364,20 @@ class Event(object):
# TODO: Clause the timestamps for zulu suffix causing datetime.datetime
# to fail substitution.
for attr in list(set(ical_event.required)):
- if ical_event.has_key(attr):
+ if attr in ical_event:
self.set_from_ical(attr.lower(), ical_event[attr])
# NOTE: Make sure to list(set()) or duplicates may arise
# NOTE: Keep the original order e.g. to read DTSTART before RECURRENCE-ID
for attr in list(OrderedDict.fromkeys(ical_event.singletons)):
- if ical_event.has_key(attr):
+ if attr in ical_event:
if isinstance(ical_event[attr], list):
ical_event[attr] = ical_event[attr][0];
self.set_from_ical(attr.lower(), ical_event[attr])
# NOTE: Make sure to list(set()) or duplicates may arise
for attr in list(set(ical_event.multiple)):
- if ical_event.has_key(attr):
+ if attr in ical_event:
self.set_from_ical(attr.lower(), ical_event[attr])
def _xml_from_ical(self, ical):
@@ -904,27 +904,27 @@ class Event(object):
else:
params = {}
- if params.has_key('CN'):
+ if 'CN' in params:
name = ustr(params['CN'])
else:
name = None
- if params.has_key('ROLE'):
+ if 'ROLE' in params:
role = params['ROLE']
else:
role = None
- if params.has_key('PARTSTAT'):
+ if 'PARTSTAT' in params:
partstat = params['PARTSTAT']
else:
partstat = None
- if params.has_key('RSVP'):
+ if 'RSVP' in params:
rsvp = params['RSVP']
else:
rsvp = None
- if params.has_key('CUTYPE'):
+ if 'CUTYPE' in params:
cutype = params['CUTYPE']
else:
cutype = kolabformat.CutypeIndividual
@@ -963,7 +963,7 @@ class Event(object):
else:
params = {}
- if params.has_key('CN'):
+ if 'CN' in params:
cn = ustr(params['CN'])
self.set_organizer(str(address), name=cn)
@@ -1177,7 +1177,7 @@ class Event(object):
def _translate_value(self, val, map):
name_map = dict([(v, k) for (k, v) in map.iteritems()])
- return name_map[val] if name_map.has_key(val) else 'UNKNOWN'
+ return name_map[val] if val in name_map else 'UNKNOWN'
def to_message(self, creator=None):
from email.MIMEMultipart import MIMEMultipart
diff --git a/pykolab/xml/note.py b/pykolab/xml/note.py
index 030b1df..735a098 100644
--- a/pykolab/xml/note.py
+++ b/pykolab/xml/note.py
@@ -19,7 +19,7 @@ def note_from_message(message):
note = note_from_string(payload)
# append attachment parts to Note object
- elif note and part.has_key('Content-ID'):
+ elif note and 'Content-ID' in part:
note._attachment_parts.append(part)
return note
@@ -100,7 +100,7 @@ class Note(kolabformat.Note):
def _translate_value(self, val, map):
name_map = dict([(v, k) for (k, v) in map.iteritems()])
- return name_map[val] if name_map.has_key(val) else 'UNKNOWN'
+ return name_map[val] if val in name_map else 'UNKNOWN'
def to_dict(self):
if not self.isValid():
diff --git a/pykolab/xml/recurrence_rule.py b/pykolab/xml/recurrence_rule.py
index 05d651c..52058ca 100644
--- a/pykolab/xml/recurrence_rule.py
+++ b/pykolab/xml/recurrence_rule.py
@@ -48,7 +48,7 @@ frequency_labels = {
}
def frequency_label(freq):
- return _(frequency_labels[freq]) if frequency_labels.has_key(freq) else _(freq)
+ return _(frequency_labels[freq]) if freq in frequency_labels else _(freq)
class RecurrenceRule(kolabformat.RecurrenceRule):
@@ -114,11 +114,11 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
}
for prop,setter in vectorimap.items():
- if vrecur.has_key(prop):
+ if prop in vrecur:
getattr(self, setter)([int(v) for v in vrecur[prop]])
for prop,setter in settermap.items():
- if vrecur.has_key(prop):
+ if prop in vrecur:
getattr(self, setter)(vrecur[prop])
def set_count(self, count):
@@ -150,7 +150,7 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
occurrence = int(wday.relative)
if str(wday)[0] == '-':
occurrence = occurrence * -1
- if self.weekday_map.has_key(weekday):
+ if weekday in self.weekday_map:
daypos.append(kolabformat.DayPos(occurrence, self.weekday_map[weekday]))
self.setByday(daypos)
@@ -182,7 +182,7 @@ class RecurrenceRule(kolabformat.RecurrenceRule):
def _translate_value(self, val, map):
name_map = dict([(v, k) for (k, v) in map.iteritems()])
- return name_map[val] if name_map.has_key(val) else 'UNKNOWN'
+ return name_map[val] if val in name_map else 'UNKNOWN'
def to_ical(self):
rrule = icalendar.vRecur(dict((k,v) for k,v in self.to_dict(True).items() if not (type(v) == str and v == '' or type(v) == list and len(v) == 0)))
diff --git a/pykolab/xml/todo.py b/pykolab/xml/todo.py
index 1c711b5..effb8be 100644
--- a/pykolab/xml/todo.py
+++ b/pykolab/xml/todo.py
@@ -29,7 +29,7 @@ def todo_from_message(message):
todo = todo_from_string(payload)
# append attachment parts to Todo object
- elif todo and part.has_key('Content-ID'):
+ elif todo and 'Content-ID' in part:
todo._attachment_parts.append(part)
return todo
@@ -82,11 +82,11 @@ class Todo(Event):
ical_todo = c
break
- log.debug("Todo.from_ical(); %r, %r, %r" % (type(ical_todo), ical_todo.has_key('ATTACH'), ical_todo.has_key('ATTENDEE')), level=8)
+ log.debug("Todo.from_ical(); %r, %r, %r" % (type(ical_todo), 'ATTACH' in ical_todo, 'ATTENDEE' in ical_todo), level=8)
# DISABLED: use the libkolab calendaring bindings to load the full iCal data
# TODO: this requires support for iCal parsing in the kolab.calendaring bindings
- if False and ical_todo.has_key('ATTACH') or [part for part in ical_todo.walk() if part.name == 'VALARM']:
+ if False and 'ATTACH' in ical_todo or [part for part in ical_todo.walk() if part.name == 'VALARM']:
if raw is None or raw == "":
raw = ical if isinstance(ical, str) else ical.to_ical()
self._xml_from_ical(raw)
@@ -94,21 +94,21 @@ class Todo(Event):
self.event = kolabformat.Todo()
for attr in list(set(ical_todo.required)):
- if ical_todo.has_key(attr):
+ if attr in ical_todo:
self.set_from_ical(attr.lower(), ical_todo[attr])
for attr in list(set(ical_todo.singletons)):
- if ical_todo.has_key(attr):
+ if attr in ical_todo:
if isinstance(ical_todo[attr], list):
ical_todo[attr] = ical_todo[attr][0];
self.set_from_ical(attr.lower(), ical_todo[attr])
for attr in list(set(ical_todo.multiple)):
- if ical_todo.has_key(attr):
+ if attr in ical_todo:
self.set_from_ical(attr.lower(), ical_todo[attr])
# although specified by RFC 2445/5545, icalendar doesn't have this property listed
- if ical_todo.has_key('PERCENT-COMPLETE'):
+ if 'PERCENT-COMPLETE' in ical_todo:
self.set_from_ical('percentcomplete', ical_todo['PERCENT-COMPLETE'])
def _xml_from_ical(self, ical):
@@ -122,16 +122,16 @@ class Todo(Event):
params = {}
_attachment = kolabformat.Attachment()
- if params.has_key('FMTTYPE'):
+ if 'FMTTYPE' in params:
mimetype = str(params['FMTTYPE'])
else:
mimetype = 'application/octet-stream'
- if params.has_key('X-LABEL'):
+ if 'X-LABEL' in params:
_attachment.setLabel(str(params['X-LABEL']))
decode = False
- if params.has_key('ENCODING'):
+ if 'ENCODING' in params:
if params['ENCODING'] == "BASE64" or params['ENCODING'] == "B":
decode = True
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index 5a58bf5..3e3fc9e 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -158,7 +158,7 @@ def property_label(propname):
"""
Return a localized name for the given object property
"""
- return _(property_labels[propname]) if property_labels.has_key(propname) else _(propname)
+ return _(property_labels[propname]) if propname in property_labels else _(propname)
def property_to_string(propname, value):
@@ -186,18 +186,18 @@ def property_to_string(propname, value):
if isinstance(value, dict):
if propname == 'attendee':
from . import attendee
- name = value['name'] if value.has_key('name') and not value['name'] == '' else value['email']
+ name = value['name'] if 'name' in value and not value['name'] == '' else value['email']
return "%s, %s" % (name, attendee.participant_status_label(value['partstat']))
elif propname == 'organizer':
- return value['name'] if value.has_key('name') and not value['name'] == '' else value['email']
+ return value['name'] if 'name' in value and not value['name'] == '' else value['email']
elif propname == 'rrule':
from . import recurrence_rule
rrule = recurrence_rule.frequency_label(value['freq']) % (value['interval'])
- if value.has_key('count') and value['count'] > 0:
+ if 'count' in value and value['count'] > 0:
rrule += " " + _("for %d times") % (value['count'])
- elif value.has_key('until') and (isinstance(value['until'], datetime.datetime) or isinstance(value['until'], datetime.date)):
+ elif 'until' in value and (isinstance(value['until'], datetime.datetime) or isinstance(value['until'], datetime.date)):
rrule += " " + _("until %s") % (value['until'].strftime(date_format))
return rrule
@@ -235,7 +235,7 @@ def property_to_string(propname, value):
return alarm
elif propname == 'attach':
- return value['label'] if value.has_key('label') else value['fmttype']
+ return value['label'] if 'label' in value else value['fmttype']
return None
@@ -250,8 +250,8 @@ def compute_diff(a, b, reduced=False):
properties.extend([x for x in b if x not in properties])
for prop in properties:
- aa = a[prop] if a.has_key(prop) else None
- bb = b[prop] if b.has_key(prop) else None
+ aa = a[prop] if prop in a else None
+ bb = b[prop] if prop in b else None
# compare two lists
if isinstance(aa, list) or isinstance(bb, list):
@@ -339,7 +339,7 @@ def compare_values(aa, bb, partial=False):
# accept partial match
if partial:
for k,v in aa.iteritems():
- if bb.has_key(k) and bb[k] == v:
+ if k in bb and bb[k] == v:
return True
return False
@@ -358,7 +358,7 @@ def reduce_properties(aa, bb):
properties.extend([x for x in bb if x not in properties])
for prop in properties:
- if not aa.has_key(prop) or not bb.has_key(prop):
+ if prop not in aa or prop not in bb:
continue
if isinstance(aa[prop], dict) and isinstance(bb[prop], dict):
(aa[prop], bb[prop]) = reduce_properties(aa[prop], bb[prop])