fix pylint 2.9 errors in awx collection

This commit is contained in:
Seth Foster 2021-06-30 14:28:35 -04:00
parent a58d571858
commit a9013c43fa
No known key found for this signature in database
GPG Key ID: 86E90D96F7184028
5 changed files with 25 additions and 24 deletions

View File

@ -206,9 +206,9 @@ def main():
# Create a datastructure to pass into our job launch
post_data = {}
for key in optional_args.keys():
if optional_args[key]:
post_data[key] = optional_args[key]
for arg_name, arg_value in optional_args.items():
if arg_value:
post_data[arg_name] = arg_value
# Attempt to look up the related items the user specified (these will fail the module if not found)
if inventory:
@ -243,8 +243,8 @@ def main():
}
param_errors = []
for variable_name in check_vars_to_prompts:
if module.params.get(variable_name) and not job_template[check_vars_to_prompts[variable_name]]:
for variable_name, prompt in check_vars_to_prompts.items():
if module.params.get(variable_name) and not job_template[prompt]:
param_errors.append("The field {0} was specified but the job template does not allow for it to be overridden".format(variable_name))
# Check if Either ask_variables_on_launch, or survey_enabled is enabled for use of extra vars.
if module.params.get('extra_vars') and not (job_template['ask_variables_on_launch'] or job_template['survey_enabled']):

View File

@ -58,7 +58,8 @@ def main():
json_output = {'changed': False}
try:
manifest = base64.b64encode(open(module.params.get('manifest'), 'rb').read())
with open(module.params.get('manifest'), 'rb') as fid:
manifest = base64.b64encode(fid.read())
except OSError as e:
module.fail_json(msg=str(e))

View File

@ -216,11 +216,11 @@ def main():
resource_param_keys = ('user', 'team', 'lookup_organization')
resources = {}
for resource_group in resource_list_param_keys:
for resource_group, old_name in resource_list_param_keys.items():
if module.params.get(resource_group) is not None:
resources.setdefault(resource_group, []).extend(module.params.get(resource_group))
if module.params.get(resource_list_param_keys[resource_group]) is not None:
resources.setdefault(resource_group, []).append(module.params.get(resource_list_param_keys[resource_group]))
if module.params.get(old_name) is not None:
resources.setdefault(resource_group, []).append(module.params.get(old_name))
for resource_group in resource_param_keys:
if module.params.get(resource_group) is not None:
resources[resource_group] = module.params.get(resource_group)
@ -251,8 +251,8 @@ def main():
# Lookup Resources
resource_data = {}
for key in resources:
for resource in resources[key]:
for key, value in resources.items():
for resource in value:
# Attempt to look up project based on the provided name or ID and lookup data
if key in resources:
if key == 'organizations':
@ -265,8 +265,8 @@ def main():
# build association agenda
associations = {}
for actor_type, actor in actor_data.items():
for key in resource_data:
for resource in resource_data[key]:
for key, value in resource_data.items():
for resource in value:
resource_roles = resource['summary_fields']['object_roles']
if role_field not in resource_roles:
available_roles = ', '.join(list(resource_roles.keys()))

View File

@ -128,9 +128,9 @@ def main():
# Create a datastructure to pass into our job launch
post_data = {}
for key in optional_args.keys():
if optional_args[key]:
post_data[key] = optional_args[key]
for arg_name, arg_value in optional_args.items():
if arg_value:
post_data[arg_name] = arg_value
# Attempt to look up the related items the user specified (these will fail the module if not found)
if inventory:
@ -154,8 +154,8 @@ def main():
}
param_errors = []
for variable_name in check_vars_to_prompts:
if variable_name in post_data and not workflow_job_template[check_vars_to_prompts[variable_name]]:
for variable_name, prompt in check_vars_to_prompts.items():
if variable_name in post_data and not workflow_job_template[prompt]:
param_errors.append("The field {0} was specified but the workflow job template does not allow for it to be overridden".format(variable_name))
# Check if Either ask_variables_on_launch, or survey_enabled is enabled for use of extra vars.
if module.params.get('extra_vars') and not (workflow_job_template['ask_variables_on_launch'] or workflow_job_template['survey_enabled']):

View File

@ -223,12 +223,12 @@ def test_completeness(collection_import, request, admin_user, job_template, exec
longest_module_name = 0
longest_option_name = 0
longest_endpoint = 0
for module in option_comparison:
if len(option_comparison[module]['module_name']) > longest_module_name:
longest_module_name = len(option_comparison[module]['module_name'])
if len(option_comparison[module]['endpoint']) > longest_endpoint:
longest_endpoint = len(option_comparison[module]['endpoint'])
for option in option_comparison[module]['api_options'], option_comparison[module]['module_options']:
for module, module_value in option_comparison.items():
if len(module_value['module_name']) > longest_module_name:
longest_module_name = len(module_value['module_name'])
if len(module_value['endpoint']) > longest_endpoint:
longest_endpoint = len(module_value['endpoint'])
for option in module_value['api_options'], module_value['module_options']:
if len(option) > longest_option_name:
longest_option_name = len(option)