simplify checking the refresh paramater

This commit is contained in:
Michael Calmer 2016-02-21 11:26:51 +01:00
parent db0e0de2fd
commit 644b14c273

View file

@ -85,7 +85,7 @@ def list_upgrades(refresh=True):
salt '*' pkg.list_upgrades
'''
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
ret = {}
call = __salt__['cmd.run_all'](
@ -199,7 +199,7 @@ def info_available(*names, **kwargs):
names = sorted(list(set(names)))
# Refresh db before extracting the latest package
if salt.utils.is_true(kwargs.pop('refresh', True)):
if kwargs.pop('refresh', True):
refresh_db()
pkg_info = []
@ -780,7 +780,7 @@ def install(name=None,
{'<package>': {'old': '<old-version>',
'new': '<new-version>'}}
'''
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
try:
@ -884,7 +884,7 @@ def upgrade(refresh=True):
'comment': '',
}
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
old = list_pkgs()
cmd = _zypper('update', '--auto-agree-with-licenses')
@ -1259,7 +1259,7 @@ def list_patterns(refresh=False):
salt '*' pkg.list_patterns
'''
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
return _get_patterns()
@ -1293,7 +1293,7 @@ def search(criteria, refresh=False):
salt '*' pkg.search <criteria>
'''
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
doc = dom.parseString(__salt__['cmd.run'](_zypper('--xmlout', 'se', criteria),
@ -1348,7 +1348,7 @@ def list_products(all=False, refresh=False):
salt '*' pkg.list_products
salt '*' pkg.list_products all=True
'''
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
ret = list()
@ -1399,7 +1399,7 @@ def download(refresh=False, *packages):
if not packages:
raise CommandExecutionError("No packages has been specified.")
if salt.utils.is_true(refresh):
if refresh:
refresh_db()
doc = dom.parseString(__salt__['cmd.run'](