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.

    If the latest version of a given package is already installed, an empty
    string will be returned for that package.

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.latest_version CSWpython
        salt '*' pkgutil.latest_version <package1> <package2> <package3> ...
    '''
    refresh = salt.utils.is_true(kwargs.pop('refresh', True))

    if not names:
        return ''
    ret = {}
    # Initialize the dict with empty strings
    for name in names:
        ret[name] = ''

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

    pkgs = list_pkgs()
    cmd = '/opt/csw/bin/pkgutil -a --parse {0}'.format(' '.join(names))
    output = __salt__['cmd.run_all'](cmd).get('stdout', '').splitlines()
    for line in output:
        try:
            name, version_rev = line.split()[1:3]
        except ValueError:
            continue

        if name in names:
            cver = pkgs.get(name, '')
            nver = version_rev.split(',')[0]
            if not cver or salt.utils.compare_versions(ver1=cver,
                                                       oper='<',
                                                       ver2=nver):
                # Remove revision for version comparison
                ret[name] = version_rev

    # Return a string if only one package name passed
    if len(names) == 1:
        return ret[names[0]]
    return ret

# available_version is being deprecated
dataset/ETHPy150Open saltstack/salt/salt/modules/pkgutil.py/latest_version/original