human
Complete this python program:
def installed(name, pkgs=None, dir=None, user=None, force_reinstall=False, registry=None, env=None):
assistant
#Here is the Python code you requested.

    """Verify that the given package is installed and is at the correct version
    (if specified).
    .. code-block:: yaml
    coffee-script:
    npm.installed:
    - user: someuser
    coffee-script@1.0.1:
    npm.installed: []
    name
    The package to install
    .. versionchanged:: 2014.7.2
    This parameter is no longer lowercased by salt so that
    case-sensitive NPM package names will work.
    pkgs
    A list of packages to install with a single npm invocation; specifying
    this argument will ignore the ``name`` argument
    .. versionadded:: 2014.7.0
    dir
    The target directory in which to install the package, or None for
    global installation
    user
    The user to run NPM with
    .. versionadded:: 0.17.0
    registry
    The NPM registry from which to install the package
    .. versionadded:: 2014.7.0
    env
    A list of environment variables to be set prior to execution. The
    format is the same as the :py:func:`cmd.run <salt.states.cmd.run>`.
    state function.
    .. versionadded:: 2014.7.0
    force_reinstall
    Install the package even if it is already installed
    """
    ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
    pkg_list = (pkgs if pkgs else [name])
    try:
        installed_pkgs = __salt__['npm.list'](dir=dir, runas=user, env=env, depth=0)
    except (CommandNotFoundError, CommandExecutionError) as err:
        ret['result'] = False
        ret['comment'] = "Error    looking    up    '{0}':    {1}".format(name, err)
        return ret
    else:
        installed_pkgs = dict(((p, info) for (p, info) in six.iteritems(installed_pkgs)))
    pkgs_satisfied = []
    pkgs_to_install = []
    def _pkg_is_installed(pkg, installed_pkgs):
        '\n                                Helper    function    to    determine    if    a    package    is    installed\n\n                                This    performs    more    complex    comparison    than    just    checking\n                                keys,    such    as    examining    source    repos    to    see    if    the    package\n                                was    installed    by    a    different    name    from    the    same    repo\n\n                                :pkg    str:    The    package    to    compare\n                                :installed_pkgs:    A    dictionary    produced    by    npm    list    --json\n                                '
        if ((pkg_name in installed_pkgs) and ('version' in installed_pkgs[pkg_name])):
            return True
        elif ('://' in pkg_name):
            for pkg_details in installed_pkgs.values():
                try:
                    pkg_from = pkg_details.get('from', '').split('://')[1]
                    if ((not pkg_from.endswith('.git')) and pkg_name.startswith('git://')):
                        pkg_from += '.git'
                    if (pkg_name.split('://')[1] == pkg_from):
                        return True
                except IndexError:
                    pass
        return False
    for pkg in pkg_list:
        (pkg_name, _, pkg_ver) = pkg.partition('@')
        pkg_name = pkg_name.strip()
        if...