From d16fe5bef3ae63c4eaf6395845bd7bec5caaea3c Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 26 Apr 2017 17:27:49 +0530 Subject: [PATCH] Minor typo and PEP8 fixes for dnf module (#23845) Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/packaging/os/dnf.py | 27 ++++++++++++++----------- test/sanity/pep8/legacy-files.txt | 1 - 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index 6451b28301..797dc1c8f9 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -172,7 +172,7 @@ def _ensure_dnf(module): if module.check_mode: module.fail_json(msg="`{0}` is not installed, but it is required" - " for the Ansible dnf module.".format(package)) + "for the Ansible dnf module.".format(package)) module.run_command(['dnf', 'install', '-y', package], check_rc=True) global dnf @@ -184,8 +184,8 @@ def _ensure_dnf(module): import dnf.subject import dnf.util except ImportError: - module.fail_json(msg="Could not import the dnf python module." - " Please install `{0}` package.".format(package)) + module.fail_json(msg="Could not import the dnf python module. " + "Please install `{0}` package.".format(package)) def _configure_base(module, base, conf_file, disable_gpg_check, installroot='/'): @@ -288,7 +288,7 @@ def _mark_package_install(module, base, pkg_spec): try: base.install(pkg_spec) except dnf.exceptions.MarkingError: - module.fail_json(msg="No package {} available.".format(pkg_spec)) + module.fail_json(msg="No package {0} available.".format(pkg_spec)) def _parse_spec_group_file(names): @@ -340,7 +340,7 @@ def ensure(module, base, state, names): environments.append(environment.id) else: module.fail_json( - msg="No group {} available.".format(group_spec)) + msg="No group {0} available.".format(group_spec)) if state in ['installed', 'present']: # Install files. @@ -409,7 +409,7 @@ def ensure(module, base, state, names): # Group is already uninstalled. pass - for envioronment in environments: + for environment in environments: try: base.environment_remove(environment) except dnf.exceptions.CompsError: @@ -427,14 +427,16 @@ def ensure(module, base, state, names): if not base.resolve(allow_erasing=allow_erasing): if failures: - module.fail_json(msg='Failed to install some of the specified packages', - failures=failures) + module.fail_json(msg='Failed to install some of the ' + 'specified packages', + failures=failures) module.exit_json(msg="Nothing to do") else: if module.check_mode: if failures: - module.fail_json(msg='Failed to install some of the specified packages', - failures=failures) + module.fail_json(msg='Failed to install some of the ' + 'specified packages', + failures=failures) module.exit_json(changed=True) base.download_packages(base.transaction.install_set) @@ -446,8 +448,9 @@ def ensure(module, base, state, names): response['results'].append("Removed: {0}".format(package)) if failures: - module.fail_json(msg='Failed to install some of the specified packages', - failures=failures) + module.fail_json(msg='Failed to install some of the ' + 'specified packages', + failures=failures) module.exit_json(**response) diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 07ed468082..56848657b4 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -659,7 +659,6 @@ lib/ansible/modules/packaging/os/apt.py lib/ansible/modules/packaging/os/apt_key.py lib/ansible/modules/packaging/os/apt_repository.py lib/ansible/modules/packaging/os/apt_rpm.py -lib/ansible/modules/packaging/os/dnf.py lib/ansible/modules/packaging/os/dpkg_selections.py lib/ansible/modules/packaging/os/homebrew.py lib/ansible/modules/packaging/os/homebrew_cask.py