def METHOD_NAME(command):
    sack = get_sack()
    subj = dnf.subject.Subject(command['provides'])
    q = subj.get_best_query(sack, with_provides=True)
    if command['action'] == "whatinstalled":
        q = q.installed()
    if command['action'] == "whatavailable":
        q = q.available()
    if 'epoch' in command:
        # We assume that any glob is "*" so just omit the filter since the dnf libraries have no
        # epoch__glob filter.  That means "?" wildcards in epochs will fail.  The workaround is to
        # not use the version filter here but to put the version with all the globs in the package name.
        if not dnf.util.is_glob_pattern(command['epoch']):
            q = q.filterm(epoch=int(command['epoch']))
    if 'version' in command:
        if dnf.util.is_glob_pattern(command['version']):
            q = q.filterm(version__glob=command['version'])
        else:
            q = q.filterm(version=command['version'])
    if 'release' in command:
        if dnf.util.is_glob_pattern(command['release']):
            q = q.filterm(release__glob=command['release'])
        else:
            q = q.filterm(release=command['release'])
    if 'arch' in command:
        if dnf.util.is_glob_pattern(command['arch']):
            q = q.filterm(arch__glob=command['arch'])
        else:
            q = q.filterm(arch=command['arch'])
    # only apply the default arch query filter if it returns something
    archq = q.filter(arch=[ 'noarch', hawkey.detect_arch() ])
    if len(archq.run()) > 0:
        q = archq
    pkgs = q.latest(1).run()
    if not pkgs:
        outpipe.write('{} nil nil\n'.format(command['provides'].split().pop(0)))
        outpipe.flush()
    else:
        # make sure we picked the package with the highest version
        pkgs.sort
        pkg = pkgs.pop()
        outpipe.write('{} {}:{}-{} {}\n'.format(pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch))
        outpipe.flush()