diff --git a/bin/kolab_smtp_access_policy.py b/bin/kolab_smtp_access_policy.py --- a/bin/kolab_smtp_access_policy.py +++ b/bin/kolab_smtp_access_policy.py @@ -184,7 +184,7 @@ http://www.postfix.org/SMTPD_POLICY_README.html """ - for key in policy_request.keys(): + for key in policy_request: # Normalize email addresses (they may contain recipient delimiters) if key in self.email_address_keys: @@ -333,7 +333,7 @@ # mapping the rule onto a key in "special_rule_values", a # dictionary with the corresponding value set to a function to # execute. - if rule in special_rule_values.keys(): + if rule in special_rule_values: special_rules = special_rule_values[rule]() if rule.startswith("-"): rules['deny'].extend(special_rules) @@ -1599,7 +1599,7 @@ global auth, mydomains if mydomains is not None: - return domain in mydomains.keys() + return domain in mydomains auth.connect() 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 @@ -28,7 +28,7 @@ if liba in files: break files.append(liba) - for m in mods.keys(): + for m in mods: files = files + select(e, mods, vars, m, 1) break diff --git a/ext/python/Tools/freeze/freeze.py b/ext/python/Tools/freeze/freeze.py --- a/ext/python/Tools/freeze/freeze.py +++ b/ext/python/Tools/freeze/freeze.py @@ -467,7 +467,7 @@ somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) - for key in makevars.keys(): + for key in makevars: somevars[key] = makevars[key] somevars['CFLAGS'] = ' '.join(cflags) # override diff --git a/kolabd/__init__.py b/kolabd/__init__.py --- a/kolabd/__init__.py +++ b/kolabd/__init__.py @@ -316,7 +316,7 @@ for domain in all_domains: log.debug(_l("Checking for domain %s") % (domain), level=8) - if domain in domain_auth.keys() and domain in primary_domains: + if domain in domain_auth and domain in primary_domains: if not domain_auth[domain].is_alive(): log.debug(_l("Domain %s isn't alive anymore.") % (domain), level=8) domain_auth[domain].terminate() @@ -325,7 +325,7 @@ log.debug(_l("Domain %s already there and alive.") % (domain), level=8) continue - elif domain in domain_auth.keys(): + elif domain in domain_auth: log.debug(_l("Domain %s should not exist any longer.") % (domain), level=8) removed_domains.append(domain) else: diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py --- a/pykolab/auth/ldap/__init__.py +++ b/pykolab/auth/ldap/__init__.py @@ -820,7 +820,7 @@ List alias domain name spaces for the current domain name space. """ if self.domains is not None: - return [s for s in self.domains.keys() if s not in self.domains.values()] + return [s for s in self.domains if s not in self.domains.values()] return [] @@ -923,7 +923,7 @@ attributes = self.get_entry_attributes(entry_dn, want_attrs) - for attribute in attributes.keys(): + for attribute in attributes: entry[attribute] = attributes[attribute] if 'preferredlanguage' not in entry: @@ -1259,7 +1259,7 @@ attrs = {} - for attribute in attributes.keys(): + for attribute in attributes: attrs[attribute.lower()] = attributes[attribute] modlist = [] @@ -2288,7 +2288,7 @@ entry_changes[result_attribute] ) - for key in entry_changes.keys(): + for key in entry_changes: entry[key] = entry_changes[key] self.set_entry_attribute(entry, key, entry[key]) @@ -2785,7 +2785,7 @@ entry = {'dn': entry_dn} entry_attrs = utils.normalize(entry_attrs) - for attr in entry_attrs.keys(): + for attr in entry_attrs: entry[attr.lower()] = entry_attrs[attr] # Ignore nstombstone objects @@ -2811,7 +2811,7 @@ # # log.debug(_l("Recipient Addresses: %r") % (rcpt_addrs), level=8) # -# for key in rcpt_addrs.keys(): +# for key in rcpt_addrs: # entry[key] = rcpt_addrs[key] # # cache.get_entry(self.domain, entry) @@ -3140,7 +3140,7 @@ ) if len(self.ldap.supported_controls) < 1: - for control_num in SUPPORTED_LDAP_CONTROLS.keys(): + for control_num in SUPPORTED_LDAP_CONTROLS: log.debug( _l("Checking for support for %s on %s") % ( SUPPORTED_LDAP_CONTROLS[control_num]['desc'], @@ -3157,7 +3157,7 @@ for (_result, _supported_controls) in _search: supported_controls = _supported_controls.values()[0] - for control_num in SUPPORTED_LDAP_CONTROLS.keys(): + for control_num in SUPPORTED_LDAP_CONTROLS: if SUPPORTED_LDAP_CONTROLS[control_num]['oid'] in \ supported_controls: 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 @@ -71,7 +71,7 @@ if uuids is None: if refreshDeletes is False: nonpresent = [] - for uuid in self.__db.keys(): + for uuid in self.__db: if uuid == 'cookie': continue if uuid in self.__presentUUIDs: continue nonpresent.append(uuid) diff --git a/pykolab/cli/cmd_acl_cleanup.py b/pykolab/cli/cmd_acl_cleanup.py --- a/pykolab/cli/cmd_acl_cleanup.py +++ b/pykolab/cli/cmd_acl_cleanup.py @@ -52,7 +52,7 @@ acls = imap.list_acls(folder) if not aci_subject == None: - if aci_subject in acls.keys(): + if aci_subject in acls: log.debug(_("Deleting ACL %s for subject %s on folder %s") % ( acls[aci_subject], aci_subject, @@ -62,7 +62,7 @@ imap.set_acl(folder, aci_subject, '') #else: - #for _aci_subject in acls.keys(): + #for _aci_subject in acls: # connect to auth(!) # find recipient result_attr=aci_subject - # if no entry, expire acl \ No newline at end of file + # if no entry, expire acl 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 @@ -64,11 +64,11 @@ secondary_rcpt_domain = conf.get('kolab', 'primary_domain') # Check if either is in fact a domain - if not primary_rcpt_domain.lower() in domains.keys(): + if not primary_rcpt_domain.lower() in domains: print(_("Domain %r is not a local domain") % (primary_rcpt_domain), file=sys.stderr) sys.exit(1) - if not secondary_rcpt_domain.lower() in domains.keys(): + if not secondary_rcpt_domain.lower() in domains: print(_("Domain %r is not a local domain") % (secondary_rcpt_domain), file=sys.stderr) sys.exit(1) diff --git a/pykolab/cli/cmd_check_quota.py b/pykolab/cli/cmd_check_quota.py --- a/pykolab/cli/cmd_check_quota.py +++ b/pykolab/cli/cmd_check_quota.py @@ -72,7 +72,7 @@ domains = auth.list_domains() folders = [] - for domain in domains.keys(): + for domain in domains: folders = imap.lm("user/%%@%s" % (domain)) domain_auth = Auth(domain=domain) diff --git a/pykolab/cli/cmd_count_domain_mailboxes.py b/pykolab/cli/cmd_count_domain_mailboxes.py --- a/pykolab/cli/cmd_count_domain_mailboxes.py +++ b/pykolab/cli/cmd_count_domain_mailboxes.py @@ -56,7 +56,7 @@ domains = auth.list_domains() folders = [] - for domain in domains.keys(): + for domain in domains: print("%s: %d" % (domain,len(imap.lm("user/%%@%s" % (domain))))) null_realm = len(imap.lm("user/%%")) diff --git a/pykolab/cli/cmd_list_domains.py b/pykolab/cli/cmd_list_domains.py --- a/pykolab/cli/cmd_list_domains.py +++ b/pykolab/cli/cmd_list_domains.py @@ -43,7 +43,7 @@ # TODO: Take a hint in --quiet, and otherwise print out a nice table # with headers and such. if isinstance(domains['list'], dict): - for domain_dn in domains['list'].keys(): + for domain_dn in domains['list']: if isinstance(domains['list'][domain_dn][dna], list): print(domains['list'][domain_dn][dna][0]) for domain_alias in domains['list'][domain_dn][dna][1:]: diff --git a/pykolab/cli/cmd_list_mailbox_acls.py b/pykolab/cli/cmd_list_mailbox_acls.py --- a/pykolab/cli/cmd_list_mailbox_acls.py +++ b/pykolab/cli/cmd_list_mailbox_acls.py @@ -62,6 +62,6 @@ print("Folder", folder) acls = imap.list_acls(folder) - for acl in acls.keys(): + for acl in acls: print(" %-13s %s" %(acls[acl], acl)) 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 @@ -90,7 +90,7 @@ metadata = imap.get_metadata(folder) if metadata.has_key(folder): - for annotation in metadata[folder].keys(): + for annotation in metadata[folder]: print(" %-49s %s" % ( annotation, metadata[folder][annotation] diff --git a/pykolab/cli/cmd_mailbox_cleanup.py b/pykolab/cli/cmd_mailbox_cleanup.py --- a/pykolab/cli/cmd_mailbox_cleanup.py +++ b/pykolab/cli/cmd_mailbox_cleanup.py @@ -185,7 +185,7 @@ folder = imap_utf7.decode(folder) acls = imap.list_acls(folder) - for subject in acls.keys(): + for subject in acls: if subject == 'anyone': log.info( _("Skipping removal of ACL %s for subject %s on folder %s") % ( diff --git a/pykolab/cli/cmd_remove_mailaddress.py b/pykolab/cli/cmd_remove_mailaddress.py --- a/pykolab/cli/cmd_remove_mailaddress.py +++ b/pykolab/cli/cmd_remove_mailaddress.py @@ -74,7 +74,7 @@ attributes = auth.get_entry_attributes(domain, recipient, mail_attributes) # See which attribute holds the value we're trying to remove - for attribute in attributes.keys(): + for attribute in attributes: if isinstance(attributes[attribute], list): if email_address in attributes[attribute]: attributes[attribute].pop(attributes[attribute].index(email_address)) diff --git a/pykolab/cli/cmd_sync_mailhost_attrs.py b/pykolab/cli/cmd_sync_mailhost_attrs.py --- a/pykolab/cli/cmd_sync_mailhost_attrs.py +++ b/pykolab/cli/cmd_sync_mailhost_attrs.py @@ -121,7 +121,7 @@ log.warning(_("No recipients for '%s' (use --delete to delete)!") % (r_folder)) for primary in list(set(domains.values())): - secondaries = [x for x in domains.keys() if domains[x] == primary] + secondaries = [x for x in domains if domains[x] == primary] folders = [] diff --git a/pykolab/cli/commands.py b/pykolab/cli/commands.py --- a/pykolab/cli/commands.py +++ b/pykolab/cli/commands.py @@ -68,7 +68,7 @@ __commands = {} - for command in commands.keys(): + for command in commands: if isinstance(command, tuple): command_group, command = command __commands[command_group] = { diff --git a/pykolab/cli/wap/cmd_system_capabilities.py b/pykolab/cli/wap/cmd_system_capabilities.py --- a/pykolab/cli/wap/cmd_system_capabilities.py +++ b/pykolab/cli/wap/cmd_system_capabilities.py @@ -41,10 +41,10 @@ print("No system capabilities") sys.exit(1) - for domain in system_capabilities['list'].keys(): + for domain in system_capabilities['list']: print("Domain capabilities for %s" % (domain)) domain_capabilities = system_capabilities['list'][domain] - for service in domain_capabilities['actions'].keys(): + for service in domain_capabilities['actions']: print(" %-15s - %r" % (service, domain_capabilities['actions'][service]['type'])) diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py --- a/pykolab/conf/__init__.py +++ b/pykolab/conf/__init__.py @@ -85,7 +85,7 @@ self.defaults = Defaults(self.plugins) # But, they should be available in our class as well - for option in self.defaults.__dict__.keys(): + for option in self.defaults.__dict__: log.debug( _("Setting %s to %r (from defaults)") % ( option, @@ -103,7 +103,7 @@ # Also set the cli options if hasattr(self, 'cli_keywords') and self.cli_keywords is not None: - for option in self.cli_keywords.__dict__.keys(): + for option in self.cli_keywords.__dict__: retval = False if hasattr(self, "check_setting_%s" % (option)): exec( @@ -144,14 +144,14 @@ file and checks, then sets everything it can find. """ - for section in self.defaults.__dict__.keys(): + for section in self.defaults.__dict__: if section == 'testing': continue if not config.has_section(section): continue - for key in self.defaults.__dict__[section].keys(): + for key in self.defaults.__dict__[section]: retval = False if not config.has_option(section, key): continue @@ -530,7 +530,7 @@ ) def set_defaults_from_cli_options(self): - for long_opt in self.cli_parser.__dict__['_long_opt'].keys(): + for long_opt in self.cli_parser.__dict__['_long_opt']: if long_opt == "--help": continue @@ -541,7 +541,7 @@ ) # But, they should be available in our class as well - for option in self.cli_parser.defaults.keys(): + for option in self.cli_parser.defaults: log.debug( _("Setting %s to %r (from the default values for CLI options)") % ( option, diff --git a/pykolab/conf/entitlement.py b/pykolab/conf/entitlement.py --- a/pykolab/conf/entitlement.py +++ b/pykolab/conf/entitlement.py @@ -192,7 +192,7 @@ # log.error(_("Error reading entitlement certificate authority file")) def get(self): - if len(self.entitlement.keys()) == 0: + if len(self.entitlement) == 0: return None else: return self.entitlement diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py --- a/pykolab/imap/__init__.py +++ b/pykolab/imap/__init__.py @@ -70,7 +70,7 @@ # For each ACL entry, see if we think it is a current, valid # entry - for acl_entry in acls.keys(): + for acl_entry in acls: # If the key 'acl_entry' does not exist in the dictionary # of valid ACL entries, this ACL entry has got to go. if acl_entry == aci_subject: @@ -244,7 +244,7 @@ del self.imap # Empty out self._imap as well - for key in self._imap.keys(): + for key in self._imap: self._imap[key].disconnect() del self._imap[key] @@ -414,7 +414,7 @@ acl_map[mode] += char current_acls = self.imap.lam(self.folder_utf7(folder)) - for current_acl in current_acls.keys(): + for current_acl in current_acls: if current_acl == identifier: _acl = current_acls[current_acl] break @@ -572,7 +572,7 @@ auth.disconnect() - if len(domains.keys()) > 0: + if len(domains) > 0: if self.domain in domains: primary = domains[self.domain] @@ -654,7 +654,7 @@ time.sleep(0.5) - for additional_folder in additional_folders.keys(): + for additional_folder in additional_folders: _add_folder = {} folder_name = additional_folder @@ -671,7 +671,7 @@ continue if "annotations" in additional_folders[additional_folder]: - for annotation in additional_folders[additional_folder]["annotations"].keys(): + for annotation in additional_folders[additional_folder]["annotations"]: self.set_metadata( folder_name, "%s" % (annotation), @@ -679,7 +679,7 @@ ) if "acls" in additional_folders[additional_folder]: - for acl in additional_folders[additional_folder]["acls"].keys(): + for acl in additional_folders[additional_folder]["acls"]: self.set_acl( folder_name, "%s" % (acl), @@ -744,7 +744,7 @@ self.logout() self.connect(domain=self.domain) - for additional_folder in additional_folders.keys(): + for additional_folder in additional_folders: if additional_folder.startswith(personal) and not personal == '': folder_name = additional_folder.replace(personal, '') else: 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 @@ -130,8 +130,8 @@ traceback.print_exc() return [] - for number in alternative_mail_routines.keys(): - for routine in alternative_mail_routines[number].keys(): + for number in alternative_mail_routines: + for routine in alternative_mail_routines[number]: try: exec("retval = '%s'.%s" % (routine,alternative_mail_routines[number][routine] % user_attrs)) 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.keys()) == 1 or not kw.has_key('user'): + if not len(kw) == 1 or not kw.has_key('user'): log.error(_("Wrong number of arguments for sieve management plugin")) return else: diff --git a/pykolab/setup/components.py b/pykolab/setup/components.py --- a/pykolab/setup/components.py +++ b/pykolab/setup/components.py @@ -64,7 +64,7 @@ __components = {} - for component in components.keys(): + for component in components: if isinstance(component, tuple): component_group, component = component __components[component_group] = { @@ -104,7 +104,7 @@ __components = {} - for component in components.keys(): + for component in components: if isinstance(component, tuple): component_group, component = component __components[component_group] = { diff --git a/pykolab/setup/setup_freebusy.py b/pykolab/setup/setup_freebusy.py --- a/pykolab/setup/setup_freebusy.py +++ b/pykolab/setup/setup_freebusy.py @@ -164,12 +164,12 @@ cfg_parser = RawConfigParser() cfg_parser.read('/etc/kolab-freebusy/config.ini') - for section in freebusy_settings.keys(): - if len(freebusy_settings[section].keys()) < 1: + for section in freebusy_settings: + if len(freebusy_settings[section]) < 1: cfg_parser.remove_section(section) continue - for key in freebusy_settings[section].keys(): + for key in freebusy_settings[section]: if not cfg_parser.has_section(section): cfg_parser.add_section(section) diff --git a/pykolab/setup/setup_mta.py b/pykolab/setup/setup_mta.py --- a/pykolab/setup/setup_mta.py +++ b/pykolab/setup/setup_mta.py @@ -245,7 +245,7 @@ if not os.path.isdir('/etc/postfix/ldap'): os.mkdir('/etc/postfix/ldap/', 0o770) - for filename in files.keys(): + for filename in files: fp = open(filename, 'w') fp.write(files[filename]) fp.close() @@ -305,7 +305,7 @@ setting_base = '/files/etc/postfix/main.cf/' - for setting_key in postfix_main_settings.keys(): + for setting_key in postfix_main_settings: setting = os.path.join(setting_base,setting_key) current_value = myaugeas.get(setting) diff --git a/pykolab/translit.py b/pykolab/translit.py --- a/pykolab/translit.py +++ b/pykolab/translit.py @@ -110,8 +110,8 @@ if translit_map.has_key(_translit_name): if translit_map[_translit_name].has_key(char): _output += translit_map[_translit_name][char] - elif char in [repr(x) for x in translit_map[_translit_name].keys()]: - _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]] + 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]] else: _output += char else: @@ -121,8 +121,8 @@ if translit_map.has_key(_translit_name): if translit_map[_translit_name].has_key(char): _output += translit_map[_translit_name][char] - elif char in [repr(x) for x in translit_map[_translit_name].keys()]: - _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]] + 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]] else: _output += char else: diff --git a/pykolab/utils.py b/pykolab/utils.py --- a/pykolab/utils.py +++ b/pykolab/utils.py @@ -198,7 +198,7 @@ str_format = "%%%ds" % max_key_length - if default == '' or default not in options.keys(): + if default == '' or default not in options: for key in keys: if options[key] == key: print(" - " + key) @@ -219,10 +219,10 @@ continue - if answer == '' and default in options.keys(): + if answer == '' and default in options: answer = default - if answer in [str(x) for x in options.keys()]: + if answer in [str(x) for x in options]: answer_correct = True return answer 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 @@ -188,14 +188,14 @@ def get_group_input(): group_types = group_types_list() - if len(group_types.keys()) > 1: - for key in group_types.keys(): + if len(group_types) > 1: + for key in group_types: if not key == "status": print("%s) %s" % (key,group_types[key]['name'])) group_type_id = utils.ask_question("Please select the group type") - elif len(group_types.keys()) > 0: + elif len(group_types) > 0: print("Automatically selected the only group type available") group_type_id = group_types.keys()[0] @@ -213,10 +213,10 @@ 'group_type_id': group_type_id } - for attribute in group_type_info['form_fields'].keys(): + for attribute in group_type_info['form_fields']: params[attribute] = utils.ask_question(attribute) - for attribute in group_type_info['auto_form_fields'].keys(): + for attribute in group_type_info['auto_form_fields']: exec("retval = group_form_value_generate_%s(params)" % (attribute)) params[attribute] = retval[attribute] @@ -227,7 +227,7 @@ if user_types['count'] > 1: print("") - for key in user_types['list'].keys(): + for key in user_types['list']: if not key == "status": print("%s) %s" % (key,user_types['list'][key]['name'])) @@ -256,7 +256,7 @@ must_attrs = [] may_attrs = [] - for attribute in user_type_info['form_fields'].keys(): + 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']: may_attrs.append(attribute) @@ -300,7 +300,7 @@ else: params[attribute] = utils.ask_question(attribute) - for attribute in user_type_info['fields'].keys(): + for attribute in user_type_info['fields']: params[attribute] = user_type_info['fields'][attribute] exec("retval = user_form_value_generate(params)") @@ -591,7 +591,7 @@ user_info = request('GET', 'user.info', get=get) - for attribute in attributes.keys(): + for attribute in attributes: user_info[attribute] = attributes[attribute] post = json.dumps(user_info) diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py --- a/pykolab/xml/attendee.py +++ b/pykolab/xml/attendee.py @@ -214,7 +214,7 @@ return name_map[val] if name_map.has_key(val) else 'UNKNOWN' def set_cutype(self, cutype): - if cutype in self.cutype_map.keys(): + if cutype in self.cutype_map: self.setCutype(self.cutype_map[cutype]) elif cutype in self.cutype_map.values(): self.setCutype(cutype) @@ -226,7 +226,7 @@ self.setContact(self.contactreference) def set_participant_status(self, participant_status): - if participant_status in self.participant_status_map.keys(): + if participant_status in self.participant_status_map: self.setPartStat(self.participant_status_map[participant_status]) elif participant_status in self.participant_status_map.values(): self.setPartStat(participant_status) @@ -234,7 +234,7 @@ raise InvalidAttendeeParticipantStatusError(_("Invalid participant status %r") % (participant_status)) def set_role(self, role): - if role in self.role_map.keys(): + if role in self.role_map: self.setRole(self.role_map[role]) elif role in self.role_map.values(): self.setRole(role) diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py --- a/pykolab/xml/event.py +++ b/pykolab/xml/event.py @@ -551,28 +551,28 @@ delegators = attendee.get_delegated_from() delegatees = attendee.get_delegated_to() - if rsvp in attendee.rsvp_map.keys(): + if rsvp in attendee.rsvp_map: _rsvp = rsvp elif rsvp in attendee.rsvp_map.values(): _rsvp = [k for k, v in attendee.rsvp_map.iteritems() if v == rsvp][0] else: _rsvp = None - if role in attendee.role_map.keys(): + if role in attendee.role_map: _role = role elif role in attendee.role_map.values(): _role = [k for k, v in attendee.role_map.iteritems() if v == role][0] else: _role = None - if partstat in attendee.participant_status_map.keys(): + if partstat in attendee.participant_status_map: _partstat = partstat elif partstat in attendee.participant_status_map.values(): _partstat = [k for k, v in attendee.participant_status_map.iteritems() if v == partstat][0] else: _partstat = None - if cutype in attendee.cutype_map.keys(): + if cutype in attendee.cutype_map: _cutype = cutype elif cutype in attendee.cutype_map.values(): _cutype = [k for k, v in attendee.cutype_map.iteritems() if v == cutype][0] @@ -608,7 +608,7 @@ def get_ical_attendee_participant_status(self, attendee): attendee = self.get_attendee(attendee) - if attendee.get_participant_status() in attendee.participant_status_map.keys(): + if attendee.get_participant_status() in attendee.participant_status_map: return attendee.get_participant_status() elif attendee.get_participant_status() in attendee.participant_status_map.values(): return [k for k, v in attendee.participant_status_map.iteritems() if v == attendee.get_participant_status()][0] @@ -652,7 +652,7 @@ def get_ical_status(self): status = self.event.status() - if status in self.status_map.keys(): + if status in self.status_map: return status return self._translate_value(status, self.status_map) if status else None @@ -814,7 +814,7 @@ self.event.setAttendees(self._attendees) def set_classification(self, classification): - if classification in self.classification_map.keys(): + if classification in self.classification_map: self.event.setClassification(self.classification_map[classification]) elif classification in self.classification_map.values(): self.event.setClassification(classification) @@ -1065,7 +1065,7 @@ self.event.setStart(xmlutils.to_cdatetime(_datetime, True)) def set_status(self, status): - if status in self.status_map.keys(): + if status in self.status_map: self.event.setStatus(self.status_map[status]) elif status in self.status_map.values(): self.event.setStatus(status) diff --git a/pykolab/xml/note.py b/pykolab/xml/note.py --- a/pykolab/xml/note.py +++ b/pykolab/xml/note.py @@ -86,7 +86,7 @@ return _class def set_classification(self, classification): - if classification in self.classification_map.keys(): + if classification in self.classification_map: self.setClassification(self.classification_map[classification]) elif classification in self.classification_map.values(): self.setClassification(status) 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 @@ -175,7 +175,7 @@ def _set_map_value(self, val, pmap, setter): if isinstance(val, list): val = val[0] - if val in pmap.keys(): + if val in pmap: getattr(self, setter)(pmap[val]) elif val in pmap.values(): getattr(self, setter)(val) diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py --- a/pykolab/xml/utils.py +++ b/pykolab/xml/utils.py @@ -247,7 +247,7 @@ diff = [] properties = a.keys() - properties.extend([x for x in b.keys() if x not in properties]) + 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 @@ -355,7 +355,7 @@ return (aa, bb) properties = aa.keys() - properties.extend([x for x in bb.keys() if x not in properties]) + 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): diff --git a/tests/functional/resource_func.py b/tests/functional/resource_func.py --- a/tests/functional/resource_func.py +++ b/tests/functional/resource_func.py @@ -30,7 +30,7 @@ type_id = 0 resource_types = wap_client.resource_types_list() - for key in resource_types['list'].keys(): + for key in resource_types['list']: if resource_types['list'][key]['key'] == type: type_id = key @@ -41,7 +41,7 @@ params = {} - for attribute in resource_type_info['form_fields'].keys(): + for attribute in resource_type_info['form_fields']: attr_details = resource_type_info['form_fields'][attribute] if isinstance(attr_details, dict): @@ -53,7 +53,7 @@ fvg_params = params fvg_params['object_type'] = 'resource' fvg_params['type_id'] = type_id - fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'].keys() if attr not in params] + fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'] if attr not in params] result = wap_client.resource_add(params) result['dn'] = "cn=" + result['cn'] + ",ou=Resources,dc=example,dc=org" diff --git a/tests/functional/test_kolabd/test_001_user_sync.py b/tests/functional/test_kolabd/test_001_user_sync.py --- a/tests/functional/test_kolabd/test_001_user_sync.py +++ b/tests/functional/test_kolabd/test_001_user_sync.py @@ -89,7 +89,7 @@ folders = imap.lm('user/%(local)s/*@%(domain)s' % (self.user)) - self.assertEqual(len(folders), len(ac_folders.keys())) + self.assertEqual(len(folders), len(ac_folders)) def test_005_user_folders_metadata_set(self): imap = IMAP() @@ -109,7 +109,7 @@ folder_name = '/'.join(folder.split('/')[2:]).split('@')[0] if folder_name in ac_folders: if 'annotations' in ac_folders[folder_name]: - for _annotation in ac_folders[folder_name]['annotations'].keys(): + for _annotation in ac_folders[folder_name]['annotations']: if _annotation.startswith('/private'): continue diff --git a/tests/functional/test_wap_client/test_002_user_add.py b/tests/functional/test_wap_client/test_002_user_add.py --- a/tests/functional/test_wap_client/test_002_user_add.py +++ b/tests/functional/test_wap_client/test_002_user_add.py @@ -51,7 +51,7 @@ print(folders) print(ac_folders.keys()) - self.assertEqual(len(folders), len(ac_folders.keys())) + self.assertEqual(len(folders), len(ac_folders)) def test_003_folders_metadata_set(self): imap = IMAP() diff --git a/tests/functional/user_add.py b/tests/functional/user_add.py --- a/tests/functional/user_add.py +++ b/tests/functional/user_add.py @@ -32,7 +32,7 @@ user_types = wap_client.user_types_list() - for key in user_types['list'].keys(): + for key in user_types['list']: if user_types['list'][key]['key'] == 'kolab': user_type_id = key @@ -42,7 +42,7 @@ 'user_type_id': user_type_id, } - for attribute in user_type_info['form_fields'].keys(): + for attribute in user_type_info['form_fields']: attr_details = user_type_info['form_fields'][attribute] if isinstance(attr_details, dict): @@ -54,6 +54,6 @@ fvg_params = params fvg_params['object_type'] = 'user' fvg_params['type_id'] = user_type_id - fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'].keys() if attr not in params] + fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'] if attr not in params] result = wap_client.user_add(params) diff --git a/tests/unit/test-002-attendee.py b/tests/unit/test-002-attendee.py --- a/tests/unit/test-002-attendee.py +++ b/tests/unit/test-002-attendee.py @@ -34,7 +34,7 @@ self.assertEqual(self.attendee.get_participant_status(), 0) def test_005_participant_status_map_length(self): - self.assertEqual(len(self.attendee.participant_status_map.keys()), 7) + self.assertEqual(len(self.attendee.participant_status_map), 7) def test_006_participant_status_map_forward_lookup(self): # Forward lookups @@ -60,7 +60,7 @@ self.assertEqual(self.attendee.get_rsvp(), 0) def test_009_rsvp_map_length(self): - self.assertEqual(len(self.attendee.rsvp_map.keys()), 2) + self.assertEqual(len(self.attendee.rsvp_map), 2) def test_010_rsvp_map_forward_lookup_boolean(self): self.assertEqual(self.attendee.rsvp_map["TRUE"], True) @@ -82,7 +82,7 @@ self.assertEqual(self.attendee.get_role(), 0) def test_015_role_map_length(self): - self.assertEqual(len(self.attendee.role_map.keys()), 4) + self.assertEqual(len(self.attendee.role_map), 4) def test_016_role_map_forward_lookup(self): self.assertEqual(self.attendee.role_map["REQ-PARTICIPANT"], 0) @@ -97,7 +97,7 @@ self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 3][0], "NON-PARTICIPANT") def test_015_cutype_map_length(self): - self.assertEqual(len(self.attendee.cutype_map.keys()), 5) + self.assertEqual(len(self.attendee.cutype_map), 5) def test_016_cutype_map_forward_lookup(self): self.assertEqual(self.attendee.cutype_map["GROUP"], kolabformat.CutypeGroup) diff --git a/ucs/kolab_sieve.py b/ucs/kolab_sieve.py --- a/ucs/kolab_sieve.py +++ b/ucs/kolab_sieve.py @@ -77,10 +77,10 @@ new = utils.normalize(args[1]) old = utils.normalize(args[2]) - if isinstance(old, dict) and len(old.keys()) > 0: + if isinstance(old, dict) and len(old) > 0: # Either the entry changed or was deleted - if isinstance(new, dict) and len(new.keys()) > 0: + if isinstance(new, dict) and len(new) > 0: # The entry was modified. result_attr = conf.get('cyrus-sasl', 'result_attribute') @@ -128,7 +128,7 @@ # Sieve Script Management return - elif isinstance(new, dict) and len(new.keys()) > 0: + elif isinstance(new, dict) and len(new) > 0: # Old is not a dict (or empty), so the entry is just created # See if the mailserver_attribute exists diff --git a/ucs/listener.py b/ucs/listener.py --- a/ucs/listener.py +++ b/ucs/listener.py @@ -83,13 +83,13 @@ new = utils.normalize(args[1]) old = utils.normalize(args[2]) - if isinstance(old, dict) and len(old.keys()) > 0: + if isinstance(old, dict) and len(old) > 0: # Two options: # - entry changed # - entry deleted log.info("user %r, old is dict" % (dn)) - if isinstance(new, dict) and len(new.keys()) > 0: + if isinstance(new, dict) and len(new) > 0: log.info("Modify entry %r" % (dn)) mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower() @@ -160,7 +160,7 @@ entry=old ) - elif isinstance(new, dict) and len(new.keys()) > 0: + elif isinstance(new, dict) and len(new) > 0: # Old is not a dict (or empty), so the entry is just created log.info("Add entry %r" % (dn)) diff --git a/wallace/module_optout.py b/wallace/module_optout.py --- a/wallace/module_optout.py +++ b/wallace/module_optout.py @@ -90,7 +90,7 @@ "Cc": [] } - for recipient_type in recipients.keys(): + for recipient_type in recipients: for recipient in recipients[recipient_type]: log.debug( _("Running opt-out consult from envelope sender '%s " + \ @@ -136,7 +136,7 @@ use_this = False - for recipient_type in _recipients[answer].keys(): + for recipient_type in _recipients[answer]: _message.__delitem__(recipient_type) if not len(_recipients[answer][recipient_type]) == 0: _message.__setitem__( diff --git a/wallace/module_resources.py b/wallace/module_resources.py --- a/wallace/module_resources.py +++ b/wallace/module_resources.py @@ -708,7 +708,7 @@ num_messages = 0 available_resource = None - for resource in resources.keys(): + for resource in resources: # skip this for resource collections if 'kolabtargetfolder' not in resources[resource]: continue diff --git a/wallace/modules.py b/wallace/modules.py --- a/wallace/modules.py +++ b/wallace/modules.py @@ -78,7 +78,7 @@ __modules = {} - for module in modules.keys(): + for module in modules: if isinstance(module, tuple): module_group, module = module __modules[module_group] = {