def is_available(self, repoq, pkgspec, 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)
            (e, m, _) = my.pkgSack.matchPackageNames([pkgspec])
            pkgs = (e + m)
            if (not pkgs):
                pkgs.extend(my.returnPackagesByDep(pkgspec))
        except Exception as e:
            self.module.fail_json(msg=('Failure talking to yum: %s' % to_native(e)))
        return [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, pkgspec])
        (rc, out, err) = self.module.run_command(cmd)
        if (rc == 0):
            return [p for p in out.split('\n') if p.strip()]
        else:
            self.module.fail_json(msg=('Error from repoquery: %s: %s' % (cmd, err)))
    return []
def is_available(self, repoq, pkgspec, 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)
            (e, m, _) = my.pkgSack.matchPackageNames([pkgspec])
            pkgs = (e + m)
            if (not pkgs):
                pkgs.extend(my.returnPackagesByDep(pkgspec))
        except Exception as e:
            self.module.fail_json(msg=('Failure talking to yum: %s' % to_native(e)))
        return [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, pkgspec])
        (rc, out, err) = self.module.run_command(cmd)
        if (rc == 0):
            return [p for p in out.split('\n') if p.strip()]
        else:
            self.module.fail_json(msg=('Error from repoquery: %s: %s' % (cmd, err)))
    return []