def what_provides(self, repoq, req_spec, qf=def_qf):
    if (not repoq):
        pkgs = []
        try:
            my = self.yum_base()
            for rid in self.disablerepo:
                my.repos.disableRepo(rid)
            for rid in self.enablerepo:
                my.repos.enableRepo(rid)
            try:
                pkgs = (my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec))
            except Exception as e:
                if ('repomd.xml signature could not be verified' in to_native(e)):
                    self.module.run_command((self.yum_basecmd + ['makecache']))
                    pkgs = (my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec))
                else:
                    raise
            if (not pkgs):
                (e, m, _) = my.pkgSack.matchPackageNames([req_spec])
                pkgs.extend(e)
                pkgs.extend(m)
                (e, m, _) = my.rpmdb.matchPackageNames([req_spec])
                pkgs.extend(e)
                pkgs.extend(m)
        except Exception as e:
            self.module.fail_json(msg=('Failure talking to yum: %s' % to_native(e)))
        return set((self.po_to_envra(p) for p in pkgs))
    else:
        myrepoq = list(repoq)
        r_cmd = ['--disablerepo', ','.join(self.disablerepo)]
        myrepoq.extend(r_cmd)
        r_cmd = ['--enablerepo', ','.join(self.enablerepo)]
        myrepoq.extend(r_cmd)
        cmd = (myrepoq + ['--qf', qf, '--whatprovides', req_spec])
        (rc, out, err) = self.module.run_command(cmd)
        cmd = (myrepoq + ['--qf', qf, req_spec])
        (rc2, out2, err2) = self.module.run_command(cmd)
        if ((rc == 0) and (rc2 == 0)):
            out += out2
            pkgs = set([p for p in out.split('\n') if p.strip()])
            if (not pkgs):
                pkgs = self.is_installed(repoq, req_spec, qf=qf)
            return pkgs
        else:
            self.module.fail_json(msg=('Error from repoquery: %s: %s' % (cmd, (err + err2))))
    return set()
def what_provides(self, repoq, req_spec, qf=def_qf):
    if (not repoq):
        pkgs = []
        try:
            my = self.yum_base()
            for rid in self.disablerepo:
                my.repos.disableRepo(rid)
            for rid in self.enablerepo:
                my.repos.enableRepo(rid)
            try:
                pkgs = (my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec))
            except Exception as e:
                if ('repomd.xml signature could not be verified' in to_native(e)):
                    self.module.run_command((self.yum_basecmd + ['makecache']))
                    pkgs = (my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec))
                else:
                    raise
            if (not pkgs):
                (e, m, _) = my.pkgSack.matchPackageNames([req_spec])
                pkgs.extend(e)
                pkgs.extend(m)
                (e, m, _) = my.rpmdb.matchPackageNames([req_spec])
                pkgs.extend(e)
                pkgs.extend(m)
        except Exception as e:
            self.module.fail_json(msg=('Failure talking to yum: %s' % to_native(e)))
        return set((self.po_to_envra(p) for p in pkgs))
    else:
        myrepoq = list(repoq)
        r_cmd = ['--disablerepo', ','.join(self.disablerepo)]
        myrepoq.extend(r_cmd)
        r_cmd = ['--enablerepo', ','.join(self.enablerepo)]
        myrepoq.extend(r_cmd)
        cmd = (myrepoq + ['--qf', qf, '--whatprovides', req_spec])
        (rc, out, err) = self.module.run_command(cmd)
        cmd = (myrepoq + ['--qf', qf, req_spec])
        (rc2, out2, err2) = self.module.run_command(cmd)
        if ((rc == 0) and (rc2 == 0)):
            out += out2
            pkgs = set([p for p in out.split('\n') if p.strip()])
            if (not pkgs):
                pkgs = self.is_installed(repoq, req_spec, qf=qf)
            return pkgs
        else:
            self.module.fail_json(msg=('Error from repoquery: %s: %s' % (cmd, (err + err2))))
    return set()