1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pipx: minor refactor (#3647)

* pipx: minor refactor

* added changelog fragment
This commit is contained in:
Alexei Znamensky 2021-11-01 19:59:15 +13:00 committed by GitHub
parent 927356dad3
commit 01887bf359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- pipx - minor refactor on the ``changed`` logic (https://github.com/ansible-collections/community.general/pull/3647).

View file

@ -215,7 +215,6 @@ class PipX(CmdStateModuleHelper):
facts = ansible_facts(self.module, gather_subset=['python'])
self.command = [facts['python']['executable'], '-m', 'pipx']
self.vars.set('will_change', False, output=False, change=True)
self.vars.set('application', self._retrieve_installed(), change=True, diff=True)
def __quit_module__(self):
@ -223,7 +222,7 @@ class PipX(CmdStateModuleHelper):
def state_install(self):
if not self.vars.application or self.vars.force:
self.vars.will_change = True
self.changed = True
if not self.module.check_mode:
self.run_command(params=['state', 'index_url', 'install_deps', 'force', 'python',
{'name_source': [self.vars.name, self.vars.source]}])
@ -235,7 +234,7 @@ class PipX(CmdStateModuleHelper):
raise ModuleHelperException(
"Trying to upgrade a non-existent application: {0}".format(self.vars.name))
if self.vars.force:
self.vars.will_change = True
self.changed = True
if not self.module.check_mode:
self.run_command(params=['state', 'index_url', 'install_deps', 'force', 'name'])
@ -249,7 +248,7 @@ class PipX(CmdStateModuleHelper):
if not self.vars.application:
raise ModuleHelperException(
"Trying to reinstall a non-existent application: {0}".format(self.vars.name))
self.vars.will_change = True
self.changed = True
if not self.module.check_mode:
self.run_command(params=['state', 'name', 'python'])
@ -258,7 +257,7 @@ class PipX(CmdStateModuleHelper):
raise ModuleHelperException(
"Trying to inject packages into a non-existent application: {0}".format(self.vars.name))
if self.vars.force:
self.vars.will_change = True
self.changed = True
if not self.module.check_mode:
self.run_command(params=['state', 'index_url', 'force', 'name', 'inject_packages'])
@ -272,7 +271,7 @@ class PipX(CmdStateModuleHelper):
def state_upgrade_all(self):
if self.vars.force:
self.vars.will_change = True
self.changed = True
if not self.module.check_mode:
self.run_command(params=['state', 'include_injected', 'force'])