Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117575745
D3241.1774861281.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
48 KB
Referenced Files
None
Subscribers
None
D3241.1774861281.diff
View Options
diff --git a/cyruslib.py b/cyruslib.py
--- a/cyruslib.py
+++ b/cyruslib.py
@@ -689,7 +689,7 @@
key = annotation.split('"')[3].replace('"','').replace("'","").strip()
_annot = annotation.split('(')[1].split(')')[0].strip()
- if not ann.has_key(folder):
+ if folder not in ann:
ann[folder] = {}
try:
diff --git a/ext/python/Tools/freeze/checkextensions.py b/ext/python/Tools/freeze/checkextensions.py
--- a/ext/python/Tools/freeze/checkextensions.py
+++ b/ext/python/Tools/freeze/checkextensions.py
@@ -18,7 +18,7 @@
for mod in unknown:
for e in extensions:
(mods, vars), liba = edict[e]
- if not mods.has_key(mod):
+ if mod not in mods:
continue
modules.append(mod)
if liba:
@@ -84,7 +84,7 @@
break
var = str[i:j]
i = j+1
- if vars.has_key(var):
+ if var in vars:
str = str[:k] + vars[var] + str[i:]
i = k
return str
diff --git a/pykolab/auth/ldap/syncrepl.py b/pykolab/auth/ldap/syncrepl.py
--- a/pykolab/auth/ldap/syncrepl.py
+++ b/pykolab/auth/ldap/syncrepl.py
@@ -17,7 +17,7 @@
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
--- a/pykolab/cli/__init__.py
+++ b/pykolab/cli/__init__.py
@@ -51,12 +51,12 @@
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
--- a/pykolab/cli/cmd_add_alias.py
+++ b/pykolab/cli/cmd_add_alias.py
@@ -103,11 +103,11 @@
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
--- a/pykolab/cli/cmd_list_mailbox_metadata.py
+++ b/pykolab/cli/cmd_list_mailbox_metadata.py
@@ -89,7 +89,7 @@
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
--- a/pykolab/cli/cmd_sync.py
+++ b/pykolab/cli/cmd_sync.py
@@ -139,7 +139,7 @@
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
--- a/pykolab/cli/commands.py
+++ b/pykolab/cli/commands.py
@@ -81,10 +81,10 @@
_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 @@
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 @@
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 @@
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
--- a/pykolab/cli/sieve/cmd_refresh.py
+++ b/pykolab/cli/sieve/cmd_refresh.py
@@ -125,28 +125,28 @@
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 @@
#
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 @@
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 @@
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 @@
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
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -219,7 +219,7 @@
level=8
)
- if self.mbox.has_key(mailfolder):
+ if mailfolder in self.mbox:
log.debug(
_(
"Possibly reproducing the find " +
@@ -248,8 +248,8 @@
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
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -43,7 +43,7 @@
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
--- a/pykolab/plugins/dynamicquota/__init__.py
+++ b/pykolab/plugins/dynamicquota/__init__.py
@@ -53,7 +53,7 @@
"""
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
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -56,12 +56,12 @@
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 @@
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 @@
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
--- a/pykolab/plugins/roundcubedb/__init__.py
+++ b/pykolab/plugins/roundcubedb/__init__.py
@@ -58,7 +58,7 @@
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
--- a/pykolab/plugins/sievemgmt/__init__.py
+++ b/pykolab/plugins/sievemgmt/__init__.py
@@ -47,7 +47,7 @@
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 @@
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 @@
#
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 @@
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 @@
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 @@
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
--- a/pykolab/setup/__init__.py
+++ b/pykolab/setup/__init__.py
@@ -37,7 +37,7 @@
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
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -77,7 +77,7 @@
_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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/translit.py
+++ b/pykolab/translit.py
@@ -98,7 +98,7 @@
}
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 @@
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 @@
_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
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -70,7 +70,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
'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
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -25,7 +25,7 @@
}
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 @@
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 @@
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 @@
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
--- a/pykolab/xml/contact.py
+++ b/pykolab/xml/contact.py
@@ -23,7 +23,7 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -39,7 +39,7 @@
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 @@
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 @@
# 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 @@
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 @@
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 @@
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
--- a/pykolab/xml/note.py
+++ b/pykolab/xml/note.py
@@ -19,7 +19,7 @@
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 @@
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
--- a/pykolab/xml/recurrence_rule.py
+++ b/pykolab/xml/recurrence_rule.py
@@ -48,7 +48,7 @@
}
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 @@
}
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 @@
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 @@
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
--- a/pykolab/xml/todo.py
+++ b/pykolab/xml/todo.py
@@ -29,7 +29,7 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -158,7 +158,7 @@
"""
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 @@
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 @@
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 @@
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 @@
# 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 @@
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])
diff --git a/wallace/module_gpgencrypt.py b/wallace/module_gpgencrypt.py
--- a/wallace/module_gpgencrypt.py
+++ b/wallace/module_gpgencrypt.py
@@ -102,7 +102,7 @@
if not os.path.isdir(os.path.join(mybasepath, stage)):
os.makedirs(os.path.join(mybasepath, stage))
- if kw.has_key('stage'):
+ if 'stage' in kw:
log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8)
log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8)
if hasattr(modules, 'cb_action_%s' % (kw['stage'])):
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -227,12 +227,12 @@
imap = IMAP()
# ignore calls on lock files
- if '/locks/' in filepath or kw.has_key('stage') and kw['stage'] == 'locks':
+ if '/locks/' in filepath or 'stage' in kw and kw['stage'] == 'locks':
return False
log.debug("Invitation policy executing for %r, %r" % (filepath, '/locks/' in filepath), level=8)
- if kw.has_key('stage'):
+ if 'stage' in kw:
log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8)
log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8)
@@ -292,7 +292,7 @@
log.debug(_("iTip objects attached to this message contain the following information: %r") % (itip_events), level=8)
# See if any iTip actually allocates a user.
- if any_itips and len([x['uid'] for x in itip_events if x.has_key('attendees') or x.has_key('organizer')]) > 0:
+ if any_itips and len([x['uid'] for x in itip_events if 'attendees' in x or 'organizer' in x]) > 0:
auth.connect()
# we're looking at the first itip object
@@ -329,7 +329,7 @@
# for replies, the organizer is the recipient
if itip_event['method'] == 'REPLY':
# Outlook can send iTip replies without an organizer property
- if itip_event.has_key('organizer'):
+ if 'organizer' in itip_event:
organizer_mailto = str(itip_event['organizer']).split(':')[-1]
user_attendees = [organizer_mailto] if organizer_mailto in recipient_emails else []
else:
@@ -337,10 +337,10 @@
else:
# Limit the attendees to the one that is actually invited with the current message.
- attendees = [str(a).split(':')[-1] for a in (itip_event['attendees'] if itip_event.has_key('attendees') else [])]
+ attendees = [str(a).split(':')[-1] for a in (itip_event['attendees'] if 'attendees' in itip_event else [])]
user_attendees = [a for a in attendees if a in recipient_emails]
- if itip_event.has_key('organizer'):
+ if 'organizer' in itip_event:
sender_email = itip_event['xml'].get_organizer().email()
# abort if no attendee matches the envelope recipient
@@ -354,7 +354,7 @@
recipient_email = user_attendees[0]
# change gettext language to the preferredlanguage setting of the receiving user
- if receiving_user.has_key('preferredlanguage'):
+ if 'preferredlanguage' in receiving_user:
pykolab.translate.setUserLanguage(receiving_user['preferredlanguage'])
# find user's kolabInvitationPolicy settings and the matching policy values
@@ -369,7 +369,7 @@
}
done = None
- if method_processing_map.has_key(itip_event['method']):
+ if itip_event['method'] in method_processing_map:
processor_func = method_processing_map[itip_event['method']]
# connect as cyrus-admin
@@ -486,7 +486,7 @@
# if RSVP, send an iTip REPLY
if rsvp or scheduling_required:
# set attendee's CN from LDAP record if yet missing
- if not receiving_attendee.get_name() and receiving_user.has_key('cn'):
+ if not receiving_attendee.get_name() and 'cn' in receiving_user:
receiving_attendee.set_name(receiving_user['cn'])
# send iTip reply
@@ -693,7 +693,7 @@
auth.connect()
# return cached value
- if user_dn_from_email_address.cache.has_key(email_address):
+ if email_address in user_dn_from_email_address.cache:
return user_dn_from_email_address.cache[email_address]
local_domains = auth.list_domains()
@@ -724,7 +724,7 @@
def get_matching_invitation_policies(receiving_user, sender_email, type_condition=COND_TYPE_ALL):
# get user's kolabInvitationPolicy settings
- policies = receiving_user['kolabinvitationpolicy'] if receiving_user.has_key('kolabinvitationpolicy') else []
+ policies = receiving_user['kolabinvitationpolicy'] if 'kolabinvitationpolicy' in receiving_user else []
if policies and not isinstance(policies, list):
policies = [policies]
@@ -742,7 +742,7 @@
if domain == '' or domain == '*' or str(sender_email).endswith(domain):
value = value.upper()
- if policy_name_map.has_key(value):
+ if value in policy_name_map:
val = policy_name_map[value]
# append if type condition matches
if val & type_condition:
@@ -767,7 +767,7 @@
mail_attribute = mail_attribute.lower()
- if not user_rec.has_key(mail_attribute):
+ if mail_attribute not in user_rec:
log.error(_("User record doesn't have the mailbox attribute %r set" % (mail_attribute)))
return False
@@ -961,7 +961,7 @@
conflict = False
# return previously detected conflict
- if itip_event.has_key('_conflicts'):
+ if '_conflicts' in itip_event:
return not itip_event['_conflicts']
for folder in list_user_folders(receiving_user, 'event'):
@@ -1087,12 +1087,12 @@
oc = object.get_classification()
# use *.confidential/private folder for confidential/private invitations
- if oc == kolabformat.ClassConfidential and user_rec.has_key('_confidential_folder'):
+ if oc == kolabformat.ClassConfidential and '_confidential_folder' in user_rec:
targetfolder = user_rec['_confidential_folder']
- elif oc == kolabformat.ClassPrivate and user_rec.has_key('_private_folder'):
+ elif oc == kolabformat.ClassPrivate and '_private_folder' in user_rec:
targetfolder = user_rec['_private_folder']
# use *.default folder if exists
- elif user_rec.has_key('_default_folder'):
+ elif '_default_folder' in user_rec:
targetfolder = user_rec['_default_folder']
# fallback to any existing folder of specified type
elif targetfolders is not None and len(targetfolders) > 0:
@@ -1205,7 +1205,7 @@
for attendee in object.get_attendees():
parstat = attendee.get_participant_status(True)
- if partstats.has_key(parstat):
+ if parstat in partstats:
partstats[parstat].append(attendee.get_displayname())
else:
partstats['PENDING'].append(attendee.get_displayname())
diff --git a/wallace/module_optout.py b/wallace/module_optout.py
--- a/wallace/module_optout.py
+++ b/wallace/module_optout.py
@@ -57,7 +57,7 @@
# TODO: Test for correct call.
filepath = args[0]
- if kw.has_key('stage'):
+ if 'stage' in kw:
log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8)
log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8)
if hasattr(modules, 'cb_action_%s' % (kw['stage'])):
diff --git a/wallace/modules.py b/wallace/modules.py
--- a/wallace/modules.py
+++ b/wallace/modules.py
@@ -133,10 +133,10 @@
log.exception(_("Module %r - Unknown error occurred; %r") % (name, errmsg))
def heartbeat(name, *args, **kw):
- if not modules.has_key(name):
+ if name not in modules:
log.warning(_("No such module %r in modules %r (1).") % (name, modules))
- if modules[name].has_key('heartbeat'):
+ if 'heartbeat' in modules[name]:
return modules[name]['heartbeat'](*args, **kw)
def _sendmail(sender, recipients, msg):
@@ -426,7 +426,7 @@
if isinstance(aliases, basestring):
aliases = [aliases]
- if modules.has_key(module):
+ if module in modules:
log.fatal(_("Module '%s' already registered") % (module))
sys.exit(1)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 30, 9:01 AM (6 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18801135
Default Alt Text
D3241.1774861281.diff (48 KB)
Attached To
Mode
D3241: [Python 3] Get rid of .has_key()
Attached
Detach File
Event Timeline