def _get_options(**kwargs):
    '''
    Returns a list of options to be used in the yum/dnf command, based on the
    kwargs passed.
    '''
    # Get repo options from the kwargs
    fromrepo = kwargs.pop('fromrepo', '')
    repo = kwargs.pop('repo', '')
    disablerepo = kwargs.pop('disablerepo', '')
    enablerepo = kwargs.pop('enablerepo', '')
    disableexcludes = kwargs.pop('disableexcludes', '')
    branch = kwargs.pop('branch', '')
    setopt = kwargs.pop('setopt', None)
    if setopt is None:
        setopt = []
    else:
        setopt = salt.utils.args.split_input(setopt)
    get_extra_options = kwargs.pop('get_extra_options', False)

    # Support old 'repo' argument
    if repo and not fromrepo:
        fromrepo = repo

    ret = []

    if fromrepo:
        log.info('Restricting to repo \'%s\'', fromrepo)
        ret.extend(['--disablerepo=*', '--enablerepo={0}'.format(fromrepo)])
    else:
        if disablerepo:
            targets = [disablerepo] \
                if not isinstance(disablerepo, list) \
                else disablerepo
            log.info('Disabling repo(s): %s', ', '.join(targets))
            ret.extend(
                ['--disablerepo={0}'.format(x) for x in targets]
            )
        if enablerepo:
            targets = [enablerepo] \
                if not isinstance(enablerepo, list) \
                else enablerepo
            log.info('Enabling repo(s): %s', ', '.join(targets))
            ret.extend(['--enablerepo={0}'.format(x) for x in targets])

    if disableexcludes:
        log.info('Disabling excludes for \'%s\'', disableexcludes)
        ret.append('--disableexcludes={0}'.format(disableexcludes))

    if branch:
        log.info('Adding branch \'%s\'', branch)
        ret.append('--branch={0}'.format(branch))

    for item in setopt:
        ret.extend(['--setopt', six.text_type(item)])

    if get_extra_options:
        # sorting here to make order uniform, makes unit testing more reliable
        for key in sorted(kwargs):
            if key.startswith('__'):
                continue
            value = kwargs[key]
            if isinstance(value, six.string_types):
                log.info('Found extra option --%s=%s', key, value)
                ret.append('--{0}={1}'.format(key, value))
            elif value is True:
                log.info('Found extra option --%s', key)
                ret.append('--{0}'.format(key))
        if ret:
            log.info('Adding extra options: %s', ret)

    return ret
Returns a list of options to be used in the yum/dnf command, based on the
    kwargs passed.