def latest_version(*names, **kwargs):
    '''
    Return the latest version of the named package available for upgrade or
    installation. If more than one package name is specified, a dict of
    name/version pairs is returned.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...
    '''
    refresh = salt.utils.data.is_true(kwargs.pop('refresh', True))

    if not names:
        return ''

    # Refresh before looking for the latest version available
    if refresh:
        refresh_db()

    ret = {}
    # Initialize the dict with empty strings
    for name in names:
        ret[name] = ''
        installed = _cpv_to_version(_vartree().dep_bestmatch(name))
        avail = _cpv_to_version(_porttree().dep_bestmatch(name))
        if avail and (not installed or salt.utils.versions.compare(ver1=installed, oper='<', ver2=avail, cmp_func=version_cmp)):
            ret[name] = avail

    # Return a string if only one package name passed
    if len(names) == 1:
        return ret[names[0]]
    return ret
def latest_version ( * names , ** kwargs ) : refresh = salt . utils . data . is_true ( kwargs . pop ( 'refresh' , True ) ) if not names : return '' if refresh : refresh_db ( ) ret = { } for name in names : ret [ name ] = '' installed = _cpv_to_version ( _vartree ( ) . dep_bestmatch ( name ) ) avail = _cpv_to_version ( _porttree ( ) . dep_bestmatch ( name ) ) if avail and ( not installed or salt . utils . versions . compare ( ver1 = installed , oper = '<' , ver2 = avail , cmp_func = version_cmp ) ) : ret [ name ] = avail if len ( names ) == 1 : return ret [ names [ 0 ] ] return ret
Return the latest version of the named package available for upgrade or
    installation. If more than one package name is specified, a dict of
    name/version pairs is returned.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...