def latest_version(*names, **kwargs):
    '''
    Return the latest version of the named package available for upgrade or
    installation

    Options:

    refresh
        Update ports with ``port selfupdate``

    CLI Example:

    .. code-block:: bash

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

    if salt.utils.data.is_true(kwargs.get('refresh', True)):
        refresh_db()

    available = _list(' '.join(names)) or {}
    installed = __salt__['pkg.list_pkgs']() or {}

    ret = {}

    for key, val in six.iteritems(available):
        if key not in installed or salt.utils.versions.compare(ver1=installed[key], oper='<', ver2=val):
            ret[key] = val
        else:
            ret[key] = '{0} (installed)'.format(version(key))

    return ret
def latest_version ( * names , ** kwargs ) : if salt . utils . data . is_true ( kwargs . get ( 'refresh' , True ) ) : refresh_db ( ) available = _list ( ' ' . join ( names ) ) or { } installed = __salt__ [ 'pkg.list_pkgs' ] ( ) or { } ret = { } for key , val in six . iteritems ( available ) : if key not in installed or salt . utils . versions . compare ( ver1 = installed [ key ] , oper = '<' , ver2 = val ) : ret [ key ] = val else : ret [ key ] = '{0} (installed)' . format ( version ( key ) ) return ret
Return the latest version of the named package available for upgrade or
    installation

    Options:

    refresh
        Update ports with ``port selfupdate``

    CLI Example:

    .. code-block:: bash

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