diff --git a/changelogs/fragments/10904-2to3-mods.yml b/changelogs/fragments/10904-2to3-mods.yml new file mode 100644 index 0000000000..12ca58b250 --- /dev/null +++ b/changelogs/fragments/10904-2to3-mods.yml @@ -0,0 +1,30 @@ +minor_changes: + - bitbucket_access_key - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - bitbucket_pipeline_known_host - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - bitbucket_pipeline_variable - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - bzr - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - capabilities - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - gitlab_milestone - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - haproxy - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - homebrew - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - homebrew_cask - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - hwc_network_vpc - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - hwc_smn_topic - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - idrac_redfish_config - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - idrac_redfish_info - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - influxdb_retention_policy - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - ini_file - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - interfaces_file - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - launchd - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - logentries - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - packet_sshkey - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - pamd - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - taiga_issue - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vdo - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vertica_role - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vertica_schema - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vertica_user - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vexata_eg - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - vexata_volume - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - xcc_redfish_command - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). + - zypper - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10904). diff --git a/plugins/modules/bitbucket_access_key.py b/plugins/modules/bitbucket_access_key.py index 3bbda218f1..2b2bf9b8c5 100644 --- a/plugins/modules/bitbucket_access_key.py +++ b/plugins/modules/bitbucket_access_key.py @@ -155,7 +155,7 @@ def get_existing_deploy_key(module, bitbucket): if info['status'] != 200: module.fail_json(msg='Failed to retrieve the list of deploy keys: {0}'.format(info)) - res = next(iter(filter(lambda v: v['label'] == module.params['label'], content['values'])), None) + res = next((v for v in content['values'] if v['label'] == module.params['label']), None) if res is not None: return res diff --git a/plugins/modules/bitbucket_pipeline_known_host.py b/plugins/modules/bitbucket_pipeline_known_host.py index 486535bbfc..fb382c8afb 100644 --- a/plugins/modules/bitbucket_pipeline_known_host.py +++ b/plugins/modules/bitbucket_pipeline_known_host.py @@ -151,7 +151,7 @@ def get_existing_known_host(module, bitbucket): if info['status'] != 200: module.fail_json(msg='Failed to retrieve list of known hosts: {0}'.format(info)) - host = next(filter(lambda v: v['hostname'] == module.params['name'], content['values']), None) + host = next((v for v in content['values'] if v['hostname'] == module.params['name']), None) if host is not None: return host diff --git a/plugins/modules/bitbucket_pipeline_variable.py b/plugins/modules/bitbucket_pipeline_variable.py index 216858e7ba..ea43beba55 100644 --- a/plugins/modules/bitbucket_pipeline_variable.py +++ b/plugins/modules/bitbucket_pipeline_variable.py @@ -139,7 +139,7 @@ def get_existing_pipeline_variable(module, bitbucket): return None page += 1 - var = next(filter(lambda v: v['key'] == module.params['name'], content['values']), None) + var = next((v for v in content['values'] if v['key'] == module.params['name']), None) if var is not None: var['name'] = var.pop('key') diff --git a/plugins/modules/bzr.py b/plugins/modules/bzr.py index 7ba3bb368a..3493b9476d 100644 --- a/plugins/modules/bzr.py +++ b/plugins/modules/bzr.py @@ -101,8 +101,9 @@ class Bzr(object): cmd = [self.bzr_path, "status", "-S"] rc, stdout, stderr = self.module.run_command(cmd, cwd=self.dest) lines = stdout.splitlines() + mods_re = re.compile('^\\?\\?.*$') - lines = filter(lambda c: not re.search('^\\?\\?.*$', c), lines) + lines = [c for c in lines if not mods_re.search(c)] return len(lines) > 0 def reset(self, force): diff --git a/plugins/modules/capabilities.py b/plugins/modules/capabilities.py index 644ddc1a46..64df086d67 100644 --- a/plugins/modules/capabilities.py +++ b/plugins/modules/capabilities.py @@ -91,7 +91,7 @@ class CapabilitiesModule(object): self.module.exit_json(changed=True, msg='capabilities changed') else: # remove from current cap list if it is already set (but op/flags differ) - current = list(filter(lambda x: x[0] != self.capability_tup[0], current)) + current = [x for x in current if x[0] != self.capability_tup[0]] # add new cap with correct op/flags current.append(self.capability_tup) self.module.exit_json(changed=True, state=self.state, msg='capabilities changed', stdout=self.setcap(self.path, current)) @@ -101,7 +101,7 @@ class CapabilitiesModule(object): self.module.exit_json(changed=True, msg='capabilities changed') else: # remove from current cap list and then set current list - current = filter(lambda x: x[0] != self.capability_tup[0], current) + current = [x for x in current if x[0] != self.capability_tup[0]] self.module.exit_json(changed=True, state=self.state, msg='capabilities changed', stdout=self.setcap(self.path, current)) self.module.exit_json(changed=False, state=self.state) diff --git a/plugins/modules/gitlab_milestone.py b/plugins/modules/gitlab_milestone.py index c33032dad5..bb4992117c 100644 --- a/plugins/modules/gitlab_milestone.py +++ b/plugins/modules/gitlab_milestone.py @@ -268,7 +268,7 @@ class GitlabMilestones(object): def get_milestone_id(self, _title): _milestone_list = self.gitlab_object.milestones.list() - _found = list(filter(lambda x: x.title == _title, _milestone_list)) + _found = [x for x in _milestone_list if x.title == _title] if _found: return _found[0].id else: diff --git a/plugins/modules/haproxy.py b/plugins/modules/haproxy.py index 22afe25c66..5fd927ba4e 100644 --- a/plugins/modules/haproxy.py +++ b/plugins/modules/haproxy.py @@ -297,7 +297,7 @@ class HAProxy(object): """ data = self.execute('show stat', 200, False).lstrip('# ') r = csv.DictReader(data.splitlines()) - return tuple(map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r))) + return tuple(d['pxname'] for d in r if d['svname'] == 'BACKEND') def discover_version(self): """ @@ -346,13 +346,11 @@ class HAProxy(object): """ data = self.execute('show stat', 200, False).lstrip('# ') r = csv.DictReader(data.splitlines()) - state = tuple( - map( - lambda d: {'status': d['status'], 'weight': d['weight'], 'scur': d['scur']}, - filter(lambda d: (pxname is None or d['pxname'] - == pxname) and d['svname'] == svname, r) - ) - ) + + def unpack_state(d): + return {'status': d['status'], 'weight': d['weight'], 'scur': d['scur']} + + state = tuple(unpack_state(d) for d in r if (pxname is None or d['pxname'] == pxname) and d['svname'] == svname) return state or None def wait_until_status(self, pxname, svname, status): diff --git a/plugins/modules/homebrew.py b/plugins/modules/homebrew.py index 7def0d955c..2b0e4408a2 100644 --- a/plugins/modules/homebrew.py +++ b/plugins/modules/homebrew.py @@ -192,7 +192,7 @@ class HomebrewException(Exception): # utils ------------------------------------------------------------------- {{{ def _create_regex_group_complement(s): lines = (line.strip() for line in s.split('\n') if line.strip()) - chars = filter(None, (line.split('#')[0].strip() for line in lines)) + chars = [_f for _f in (line.split('#')[0].strip() for line in lines) if _f] group = r'[^' + r''.join(chars) + r']' return re.compile(group) diff --git a/plugins/modules/homebrew_cask.py b/plugins/modules/homebrew_cask.py index cb60e659bd..ac88e1bafe 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -169,7 +169,7 @@ class HomebrewCaskException(Exception): # utils ------------------------------------------------------------------- {{{ def _create_regex_group_complement(s): lines = (line.strip() for line in s.split('\n') if line.strip()) - chars = filter(None, (line.split('#')[0].strip() for line in lines)) + chars = [_f for _f in (line.split('#')[0].strip() for line in lines) if _f] group = r'[^' + r''.join(chars) + r']' return re.compile(group) # /utils ------------------------------------------------------------------ }}} diff --git a/plugins/modules/hwc_network_vpc.py b/plugins/modules/hwc_network_vpc.py index eef670dd1d..b974831c87 100644 --- a/plugins/modules/hwc_network_vpc.py +++ b/plugins/modules/hwc_network_vpc.py @@ -376,13 +376,13 @@ def response_to_hash(module, response): This is for doing comparisons with Ansible's current parameters. """ return { - u'id': response.get(u'id'), - u'name': response.get(u'name'), - u'cidr': response.get(u'cidr'), - u'status': response.get(u'status'), - u'routes': VpcRoutesArray( - response.get(u'routes', []), module).from_response(), - u'enable_shared_snat': response.get(u'enable_shared_snat') + 'id': response.get('id'), + 'name': response.get('name'), + 'cidr': response.get('cidr'), + 'status': response.get('status'), + 'routes': VpcRoutesArray( + response.get('routes', []), module).from_response(), + 'enable_shared_snat': response.get('enable_shared_snat') } @@ -480,14 +480,14 @@ class VpcRoutesArray(object): def _request_for_item(self, item): return { - u'destination': item.get('destination'), - u'nexthop': item.get('next_hop') + 'destination': item.get('destination'), + 'nexthop': item.get('next_hop') } def _response_from_item(self, item): return { - u'destination': item.get(u'destination'), - u'next_hop': item.get(u'nexthop') + 'destination': item.get('destination'), + 'next_hop': item.get('nexthop') } diff --git a/plugins/modules/hwc_smn_topic.py b/plugins/modules/hwc_smn_topic.py index 328458b2d4..6fb9a3814d 100644 --- a/plugins/modules/hwc_smn_topic.py +++ b/plugins/modules/hwc_smn_topic.py @@ -312,13 +312,12 @@ def response_to_hash(module, response): This is for doing comparisons with Ansible's current parameters. """ return { - u'create_time': response.get(u'create_time'), - u'display_name': response.get(u'display_name'), - u'name': response.get(u'name'), - u'push_policy': _push_policy_convert_from_response( - response.get('push_policy')), - u'topic_urn': response.get(u'topic_urn'), - u'update_time': response.get(u'update_time') + 'create_time': response.get('create_time'), + 'display_name': response.get('display_name'), + 'name': response.get('name'), + 'push_policy': _push_policy_convert_from_response(response.get('push_policy')), + 'topic_urn': response.get('topic_urn'), + 'update_time': response.get('update_time') } diff --git a/plugins/modules/idrac_redfish_config.py b/plugins/modules/idrac_redfish_config.py index 2a85b43903..e7d6250624 100644 --- a/plugins/modules/idrac_redfish_config.py +++ b/plugins/modules/idrac_redfish_config.py @@ -205,14 +205,14 @@ class IdracRedfishUtils(RedfishUtils): for attr_name, attr_value in attributes.items(): # Check if attribute exists - if attr_name not in data[u'Attributes']: + if attr_name not in data['Attributes']: # Skip and proceed to next attribute if this isn't valid attrs_bad.update({attr_name: attr_value}) continue # Find out if value is already set to what we want. If yes, exclude # those attributes - if data[u'Attributes'][attr_name] == attr_value: + if data['Attributes'][attr_name] == attr_value: attrs_skipped.update({attr_name: attr_value}) else: attrs_to_patch.update({attr_name: attr_value}) diff --git a/plugins/modules/idrac_redfish_info.py b/plugins/modules/idrac_redfish_info.py index 6a2ec493b3..309cefc15f 100644 --- a/plugins/modules/idrac_redfish_info.py +++ b/plugins/modules/idrac_redfish_info.py @@ -149,8 +149,8 @@ class IdracRedfishUtils(RedfishUtils): # Manager attributes are supported as part of iDRAC OEM extension # Attributes are supported only on iDRAC9 try: - for members in data[u'Links'][u'Oem'][u'Dell'][u'DellAttributes']: - attributes_uri = members[u'@odata.id'] + for members in data['Links']['Oem']['Dell']['DellAttributes']: + attributes_uri = members['@odata.id'] response = self.get_request(self.root_uri + attributes_uri) if response['ret'] is False: diff --git a/plugins/modules/influxdb_retention_policy.py b/plugins/modules/influxdb_retention_policy.py index 6496e37af4..c1848a4694 100644 --- a/plugins/modules/influxdb_retention_policy.py +++ b/plugins/modules/influxdb_retention_policy.py @@ -181,7 +181,7 @@ def parse_duration_literal(value, extended=False): lookup = (EXTENDED_DURATION_REGEX if extended else DURATION_REGEX).findall(value) for duration_literal in lookup: - filtered_literal = list(filter(None, duration_literal)) + filtered_literal = [_f for _f in duration_literal if _f] duration_val = float(filtered_literal[0]) duration += duration_val * DURATION_UNIT_NANOSECS[filtered_literal[1]] diff --git a/plugins/modules/ini_file.py b/plugins/modules/ini_file.py index 7a5a514a38..27b55c3bf4 100644 --- a/plugins/modules/ini_file.py +++ b/plugins/modules/ini_file.py @@ -342,30 +342,30 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, ini_lines = [to_text(line) for line in ini_file.readlines()] if module._diff: - diff['before'] = u''.join(ini_lines) + diff['before'] = ''.join(ini_lines) changed = False # ini file could be empty if not ini_lines: - ini_lines.append(u'\n') + ini_lines.append('\n') # last line of file may not contain a trailing newline - if ini_lines[-1] == u"" or ini_lines[-1][-1] != u'\n': - ini_lines[-1] += u'\n' + if ini_lines[-1] == "" or ini_lines[-1][-1] != '\n': + ini_lines[-1] += '\n' changed = True # append fake section lines to simplify the logic # At top: # Fake random section to do not match any other in the file # Using commit hash as fake section name - fake_section_name = u"ad01e11446efb704fcdbdb21f2c43757423d91c5" + fake_section_name = "ad01e11446efb704fcdbdb21f2c43757423d91c5" # Insert it at the beginning - ini_lines.insert(0, u'[%s]' % fake_section_name) + ini_lines.insert(0, '[%s]' % fake_section_name) # At bottom: - ini_lines.append(u'[') + ini_lines.append('[') # If no section is defined, fake section is used if not section: @@ -375,9 +375,9 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, section_start = section_end = 0 msg = 'OK' if no_extra_spaces: - assignment_format = u'%s=%s\n' + assignment_format = '%s=%s\n' else: - assignment_format = u'%s = %s\n' + assignment_format = '%s = %s\n' option_no_value_present = False @@ -390,7 +390,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, for index, line in enumerate(ini_lines): # end of section: - if within_section and line.startswith(u'['): + if within_section and line.startswith('['): if check_section_has_values( section_has_values, ini_lines[section_start:index] ): @@ -434,7 +434,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, matched_value = match.group(8) if not matched_value and allow_no_value: # replace existing option with no value line(s) - newline = u'%s\n' % option + newline = '%s\n' % option option_no_value_present = True else: # replace existing option=value line(s) @@ -443,7 +443,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, values.remove(matched_value) elif not values and allow_no_value: # replace existing option with no value line(s) - newline = u'%s\n' % option + newline = '%s\n' % option (changed, msg) = update_section_line(option, changed, section_lines, index, changed_lines, ignore_spaces, newline, msg) option_no_value_present = True break @@ -482,12 +482,12 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, changed = True elif element is None and allow_no_value: # insert option with no value line - section_lines.insert(index, u'%s\n' % option) + section_lines.insert(index, '%s\n' % option) msg = 'option added' changed = True elif option and not values and allow_no_value and not option_no_value_present: # insert option with no value line(s) - section_lines.insert(index, u'%s\n' % option) + section_lines.insert(index, '%s\n' % option) msg = 'option added' changed = True break @@ -523,7 +523,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, del ini_lines[-1:] if not within_section and state == 'present': - ini_lines.append(u'[%s]\n' % section) + ini_lines.append('[%s]\n' % section) msg = 'section and option added' if section_has_values: for condition in section_has_values: @@ -532,7 +532,7 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, for value in condition['values']: ini_lines.append(assignment_format % (condition['option'], value)) elif allow_no_value: - ini_lines.append(u'%s\n' % condition['option']) + ini_lines.append('%s\n' % condition['option']) elif not exclusive: for value in condition['values']: if value not in values: @@ -541,13 +541,13 @@ def do_ini(module, filename, section=None, section_has_values=None, option=None, for value in values: ini_lines.append(assignment_format % (option, value)) elif option and not values and allow_no_value: - ini_lines.append(u'%s\n' % option) + ini_lines.append('%s\n' % option) else: msg = 'only section added' changed = True if module._diff: - diff['after'] = u''.join(ini_lines) + diff['after'] = ''.join(ini_lines) backup_file = None if changed and not module.check_mode: diff --git a/plugins/modules/interfaces_file.py b/plugins/modules/interfaces_file.py index ead71fe6f7..c7038d1008 100644 --- a/plugins/modules/interfaces_file.py +++ b/plugins/modules/interfaces_file.py @@ -303,7 +303,7 @@ def set_interface_option(module, lines, iface, option, raw_value, state, address changed, lines = addOptionAfterLine(option, value, iface, lines, last_line_dict, iface_options, address_family) else: if option in ["pre-up", "up", "down", "post-up"]: - if len(list(filter(lambda i: i['value'] == value, target_options))) < 1: + if len([i for i in target_options if i['value'] == value]) < 1: changed, lines = addOptionAfterLine(option, value, iface, lines, target_options[-1], iface_options, address_family) else: # if more than one option found edit the last one diff --git a/plugins/modules/launchd.py b/plugins/modules/launchd.py index 668388d7b6..c7e98f2bc0 100644 --- a/plugins/modules/launchd.py +++ b/plugins/modules/launchd.py @@ -258,8 +258,7 @@ class Plist: return self.__file -class LaunchCtlTask(object): - __metaclass__ = ABCMeta +class LaunchCtlTask(metaclass=ABCMeta): WAITING_TIME = 5 # seconds def __init__(self, module, service, plist): diff --git a/plugins/modules/logentries.py b/plugins/modules/logentries.py index ac7fee2f00..535ef57a2a 100644 --- a/plugins/modules/logentries.py +++ b/plugins/modules/logentries.py @@ -149,7 +149,7 @@ def main(): # Handle multiple log files logs = p["path"].split(",") - logs = filter(None, logs) + logs = [_f for _f in logs if _f] if p["state"] in ["present", "followed"]: follow_log(module, le_path, logs, name=p['name'], logtype=p['logtype']) diff --git a/plugins/modules/packet_sshkey.py b/plugins/modules/packet_sshkey.py index d7f4635bc6..a6962e34c0 100644 --- a/plugins/modules/packet_sshkey.py +++ b/plugins/modules/packet_sshkey.py @@ -174,7 +174,7 @@ def get_sshkey_selector(module): def act_on_sshkeys(target_state, module, packet_conn): selector = get_sshkey_selector(module) existing_sshkeys = packet_conn.list_ssh_keys() - matching_sshkeys = filter(selector, existing_sshkeys) + matching_sshkeys = list(filter(selector, existing_sshkeys)) changed = False if target_state == 'present': if matching_sshkeys == []: diff --git a/plugins/modules/taiga_issue.py b/plugins/modules/taiga_issue.py index ccaa164529..9927ef5c69 100644 --- a/plugins/modules/taiga_issue.py +++ b/plugins/modules/taiga_issue.py @@ -167,28 +167,28 @@ def manage_issue(taiga_host, project_name, issue_subject, issue_priority, api.auth(username=username, password=password) user_id = api.me().id - project_list = list(filter(lambda x: x.name == project_name, api.projects.list(member=user_id))) + project_list = [x for x in api.projects.list(member=user_id) if x.name == project_name] if len(project_list) != 1: return False, changed, "Unable to find project %s" % project_name, {} project = project_list[0] project_id = project.id - priority_list = list(filter(lambda x: x.name == issue_priority, api.priorities.list(project=project_id))) + priority_list = [x for x in api.priorities.list(project=project_id) if x.name == issue_priority] if len(priority_list) != 1: return False, changed, "Unable to find issue priority %s for project %s" % (issue_priority, project_name), {} priority_id = priority_list[0].id - status_list = list(filter(lambda x: x.name == issue_status, api.issue_statuses.list(project=project_id))) + status_list = [x for x in api.issue_statuses.list(project=project_id) if x.name == issue_status] if len(status_list) != 1: return False, changed, "Unable to find issue status %s for project %s" % (issue_status, project_name), {} status_id = status_list[0].id - type_list = list(filter(lambda x: x.name == issue_type, project.list_issue_types())) + type_list = [x for x in project.list_issue_types() if x.name == issue_type] if len(type_list) != 1: return False, changed, "Unable to find issue type %s for project %s" % (issue_type, project_name), {} type_id = type_list[0].id - severity_list = list(filter(lambda x: x.name == issue_severity, project.list_severities())) + severity_list = [x for x in project.list_severities() if x.name == issue_severity] if len(severity_list) != 1: return False, changed, "Unable to find severity %s for project %s" % (issue_severity, project_name), {} severity_id = severity_list[0].id @@ -205,7 +205,7 @@ def manage_issue(taiga_host, project_name, issue_subject, issue_priority, } # An issue is identified by the project_name, the issue_subject and the issue_type - matching_issue_list = list(filter(lambda x: x.subject == issue_subject and x.type == type_id, project.list_issues())) + matching_issue_list = [x for x in project.list_issues() if x.subject == issue_subject and x.type == type_id] matching_issue_list_len = len(matching_issue_list) if matching_issue_list_len == 0: diff --git a/plugins/modules/vdo.py b/plugins/modules/vdo.py index 32ebae46c1..e1338036ac 100644 --- a/plugins/modules/vdo.py +++ b/plugins/modules/vdo.py @@ -270,7 +270,7 @@ def inventory_vdos(module, vdocmd): def list_running_vdos(module, vdocmd): rc, vdolistout, err = module.run_command([vdocmd, "list"]) - runningvdolist = filter(None, vdolistout.split('\n')) + runningvdolist = [_f for _f in vdolistout.split('\n') if _f] return runningvdolist diff --git a/plugins/modules/vertica_role.py b/plugins/modules/vertica_role.py index 31c704279e..10c5e42266 100644 --- a/plugins/modules/vertica_role.py +++ b/plugins/modules/vertica_role.py @@ -194,7 +194,7 @@ def main(): assigned_roles = [] if module.params['assigned_roles']: assigned_roles = module.params['assigned_roles'].split(',') - assigned_roles = filter(None, assigned_roles) + assigned_roles = [_f for _f in assigned_roles if _f] state = module.params['state'] db = '' if module.params['db']: diff --git a/plugins/modules/vertica_schema.py b/plugins/modules/vertica_schema.py index eab3c62373..0f939ef719 100644 --- a/plugins/modules/vertica_schema.py +++ b/plugins/modules/vertica_schema.py @@ -256,11 +256,11 @@ def main(): usage_roles = [] if module.params['usage_roles']: usage_roles = module.params['usage_roles'].split(',') - usage_roles = filter(None, usage_roles) + usage_roles = [_f for _f in usage_roles if _f] create_roles = [] if module.params['create_roles']: create_roles = module.params['create_roles'].split(',') - create_roles = filter(None, create_roles) + create_roles = [_f for _f in create_roles if _f] owner = module.params['owner'] state = module.params['state'] db = '' diff --git a/plugins/modules/vertica_user.py b/plugins/modules/vertica_user.py index 6f90ee55a8..9d3aac3cdd 100644 --- a/plugins/modules/vertica_user.py +++ b/plugins/modules/vertica_user.py @@ -320,7 +320,7 @@ def main(): roles = [] if module.params['roles']: roles = module.params['roles'].split(',') - roles = filter(None, roles) + roles = [_f for _f in roles if _f] state = module.params['state'] if state == 'locked': locked = True diff --git a/plugins/modules/vexata_eg.py b/plugins/modules/vexata_eg.py index a9c73bceb7..94f99dbea4 100644 --- a/plugins/modules/vexata_eg.py +++ b/plugins/modules/vexata_eg.py @@ -84,7 +84,7 @@ def get_eg(module, array): name = module.params['name'] try: egs = array.list_egs() - eg = filter(lambda eg: eg['name'] == name, egs) + eg = [eg for eg in egs if eg['name'] == name] if len(eg) == 1: return eg[0] else: @@ -98,7 +98,7 @@ def get_vg_id(module, array): name = module.params['vg'] try: vgs = array.list_vgs() - vg = filter(lambda vg: vg['name'] == name, vgs) + vg = [vg for vg in vgs if vg['name'] == name] if len(vg) == 1: return vg[0]['id'] else: @@ -112,7 +112,7 @@ def get_ig_id(module, array): name = module.params['ig'] try: igs = array.list_igs() - ig = filter(lambda ig: ig['name'] == name, igs) + ig = [ig for ig in igs if ig['name'] == name] if len(ig) == 1: return ig[0]['id'] else: @@ -126,7 +126,7 @@ def get_pg_id(module, array): name = module.params['pg'] try: pgs = array.list_pgs() - pg = filter(lambda pg: pg['name'] == name, pgs) + pg = [pg for pg in pgs if pg['name'] == name] if len(pg) == 1: return pg[0]['id'] else: diff --git a/plugins/modules/vexata_volume.py b/plugins/modules/vexata_volume.py index 1ae2050141..b52e8fdc01 100644 --- a/plugins/modules/vexata_volume.py +++ b/plugins/modules/vexata_volume.py @@ -81,7 +81,7 @@ def get_volume(module, array): name = module.params['name'] try: vols = array.list_volumes() - vol = filter(lambda v: v['name'] == name, vols) + vol = [v for v in vols if v['name'] == name] if len(vol) == 1: return vol[0] else: diff --git a/plugins/modules/xcc_redfish_command.py b/plugins/modules/xcc_redfish_command.py index 9ddb4a5ce1..151c8eff3a 100644 --- a/plugins/modules/xcc_redfish_command.py +++ b/plugins/modules/xcc_redfish_command.py @@ -348,8 +348,8 @@ class XCCRedfishUtils(RedfishUtils): return response data = response['data'] virt_media_list = [] - for member in data[u'Members']: - virt_media_list.append(member[u'@odata.id']) + for member in data['Members']: + virt_media_list.append(member['@odata.id']) resources, headers = self._read_virt_media_resources(virt_media_list) # find the VirtualMedia resource to eject @@ -422,8 +422,8 @@ class XCCRedfishUtils(RedfishUtils): return response data = response['data'] virt_media_list = [] - for member in data[u'Members']: - virt_media_list.append(member[u'@odata.id']) + for member in data['Members']: + virt_media_list.append(member['@odata.id']) resources, headers = self._read_virt_media_resources(virt_media_list) # eject all inserted media one by one @@ -477,8 +477,8 @@ class XCCRedfishUtils(RedfishUtils): return response data = response['data'] virt_media_list = [] - for member in data[u'Members']: - virt_media_list.append(member[u'@odata.id']) + for member in data['Members']: + virt_media_list.append(member['@odata.id']) resources, headers = self._read_virt_media_resources(virt_media_list) # see if image already inserted; if so, nothing to do diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index 6c7b6d101a..3e979bce97 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -641,7 +641,7 @@ def main(): update_cache = module.params['update_cache'] # remove empty strings from package list - name = list(filter(None, name)) + name = [_f for _f in name if _f] # Refresh repositories if update_cache and not module.check_mode: