def for_each_package_specs(ns, pkg_specs, info, func,
        repoid=None, just_on_installed=True):
    """
    Iterate over package specification strings, find them on remote host,
    make them into ``LMI_SoftwareIdentity``, and pass them to given function.

    :param list pkg_specs: Package specification strings.
    :param string info: What is done with package. This is used in log messages.
    :param callable func: Any callable taking instance of
        ``LMI_SoftwareIdentity`` as the first and only argument.
    :param string repoid: Optional repository id used in a search
        for corresponding software identity.
    :param boolean just_on_installed: Skip uninstalled software identities
        found.
    :returns: Pair with list containing a subset of ``pkg_specs`` with items,
        that were processed successfuly and a list of errors for other packages.
    :rtype: tuple
    """
    done_on = []
    failed = []
    for pkg_spec in pkg_specs:
        if just_on_installed:
            identities = [
                        i.to_instance()
                    for i in software.find_package(ns,
                        pkg_spec=pkg_spec, repoid=repoid)]

            identities = [p for p in identities
                            if software.is_package_installed(p)]
        else:
            identities = list(software.find_package(ns,
                pkg_spec=pkg_spec, repoid=repoid))
        if len(identities) < 1:
            if just_on_installed:
                msg = 'No such installed package "%s".' % pkg_spec
            else:
                msg = 'Failed to find package "%s".' % pkg_spec
            LOG().warn(msg + ' Skipping.')
            failed.append(msg)
            continue
        if len(identities) > 1:
            LOG().debug('More than one package found for "%s": %s',
                    pkg_spec,
                    ', '.join(software.get_package_nevra(i)
                        for i in identities))
        try:
            func(identities[-1])
            done_on.append(pkg_spec)
        except errors.LmiFailed as err:
            failed.append(err)
    return done_on, failed
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/software/lmi/scripts/software/cmd.py/for_each_package_specs/original