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

pkgng: refactor upgraded pattern matching

Implement russoz's suggestion to put all
variants in the pattern.
This commit is contained in:
Ross Williams 2021-10-09 12:50:30 +00:00
parent 752817cf5a
commit d54f84f227

View file

@ -191,10 +191,9 @@ def upgrade_packages(module, pkgng_path, dir_arg):
cmd += " -n"
rc, out, err = module.run_command(cmd)
for action in ('upgraded', 'reinstalled',):
match = re.search('^Number of packages to be %s: ([0-9]+)' % (action,), out, re.MULTILINE)
if match:
upgraded_c += int(match.group(1))
matches = re.findall('^Number of packages to be (?:upgraded|reinstalled): ([0-9]+)', out, re.MULTILINE)
for match in matches:
upgraded_c += int(match)
if upgraded_c > 0:
return (True, "updated %s package(s)" % upgraded_c, out, err)