def latest_version(*names, **kwargs):
 kwargs.pop('refresh', True)
 pkgs = list_pkgs()
 ret = {}
 for name in names:
  ret[name] = ''
 cmd = 'pkg_info -q -I {0}'.format(' '.join(names))
 out = __salt__['cmd.run_stdout'](cmd, python_shell=False, output_loglevel='trace')
 for line in out.splitlines():
  try:
   (pkgname, pkgver, flavor) = __PKG_RE.match(line).groups()
  except AttributeError:
   continue
  pkgname += ('--{0}'.format(flavor) if flavor else '')
  cur = pkgs.get(pkgname, '')
  if ((not cur) or salt.utils.compare_versions(ver1=cur, oper='<', ver2=pkgver)):
   ret[pkgname] = pkgver
 if (len(names) == 1):
  return ret[names[0]]
 return ret

def latest_version ( * names , ** kwargs ) : kwargs . pop ( 'refresh' , True ) pkgs = list_pkgs ( ) ret = { } for name in names : ret [ name ] = '' cmd = 'pkg_info -q -I {0}' . format ( ' ' . join ( names ) ) out = __salt__ [ 'cmd.run_stdout' ] ( cmd , python_shell = False , output_loglevel = 'trace' ) for line in out . splitlines ( ) : try : ( pkgname , pkgver , flavor ) = __PKG_RE . match ( line ) . groups ( ) except AttributeError : continue pkgname += ( '--{0}' . format ( flavor ) if flavor else '' ) cur = pkgs . get ( pkgname , '' ) if ( ( not cur ) or salt . utils . compare_versions ( ver1 = cur , oper = '<' , ver2 = pkgver ) ) : ret [ pkgname ] = pkgver if ( len ( names ) == 1 ) : return ret [ names [ 0 ] ] return ret
return the latest version of the named package available for upgrade or installation .