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
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 # Create a datastructure to pass into our job launch
post_data = {} post_data = {}
for key in optional_args.keys(): for arg_name, arg_value in optional_args.items():
if optional_args[key]: if arg_value:
post_data[key] = optional_args[key] post_data[arg_name] = arg_value
# Attempt to look up the related items the user specified (these will fail the module if not found) # Attempt to look up the related items the user specified (these will fail the module if not found)
if inventory: if inventory:
@@ -243,8 +243,8 @@ def main():
} }
param_errors = [] param_errors = []
for variable_name in check_vars_to_prompts: for variable_name, prompt in check_vars_to_prompts.items():
if module.params.get(variable_name) and not job_template[check_vars_to_prompts[variable_name]]: 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)) 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. # 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']): 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} json_output = {'changed': False}
try: 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: except OSError as e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))

View File

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

View File

@@ -128,9 +128,9 @@ def main():
# Create a datastructure to pass into our job launch # Create a datastructure to pass into our job launch
post_data = {} post_data = {}
for key in optional_args.keys(): for arg_name, arg_value in optional_args.items():
if optional_args[key]: if arg_value:
post_data[key] = optional_args[key] post_data[arg_name] = arg_value
# Attempt to look up the related items the user specified (these will fail the module if not found) # Attempt to look up the related items the user specified (these will fail the module if not found)
if inventory: if inventory:
@@ -154,8 +154,8 @@ def main():
} }
param_errors = [] param_errors = []
for variable_name in check_vars_to_prompts: for variable_name, prompt in check_vars_to_prompts.items():
if variable_name in post_data and not workflow_job_template[check_vars_to_prompts[variable_name]]: 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)) 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. # 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']): 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_module_name = 0
longest_option_name = 0 longest_option_name = 0
longest_endpoint = 0 longest_endpoint = 0
for module in option_comparison: for module, module_value in option_comparison.items():
if len(option_comparison[module]['module_name']) > longest_module_name: if len(module_value['module_name']) > longest_module_name:
longest_module_name = len(option_comparison[module]['module_name']) longest_module_name = len(module_value['module_name'])
if len(option_comparison[module]['endpoint']) > longest_endpoint: if len(module_value['endpoint']) > longest_endpoint:
longest_endpoint = len(option_comparison[module]['endpoint']) longest_endpoint = len(module_value['endpoint'])
for option in option_comparison[module]['api_options'], option_comparison[module]['module_options']: for option in module_value['api_options'], module_value['module_options']:
if len(option) > longest_option_name: if len(option) > longest_option_name:
longest_option_name = len(option) longest_option_name = len(option)