def genrepo(opts=None, fire_event=True):
    '''
    Generate winrepo_cachefile based on sls files in the winrepo_dir

    opts
        Specify an alternate opts dict. Should not be used unless this function
        is imported into an execution module.

    fire_event : True
        Fire an event on failure. Only supported on the master.

    CLI Example:

    .. code-block:: bash

        salt-run winrepo.genrepo
    '''
    if opts is None:
        opts = __opts__

    if opts in 'win_repo':
        salt.utils.warn_until(
            'Nitrogen',
            'The \'win_repo\' config option is deprecated, please use '
            '\'winrepo_dir\' instead.'
        )
        winrepo_dir = opts['win_repo']
    else:
        winrepo_dir = opts['winrepo_dir']

    if 'win_repo_mastercachefile' in opts:
        salt.utils.warn_until(
            'Nitrogen',
            'The \'win_repo_mastercachefile\' config option is deprecated, '
            'please use \'winrepo_cachefile\' instead.'
        )
        winrepo_cachefile = opts['win_repo_mastercachefile']
    else:
        winrepo_cachefile = opts['winrepo_cachefile']

    ret = {}
    if not os.path.exists(winrepo_dir):
        os.makedirs(winrepo_dir)
    renderers = salt.loader.render(opts, __salt__)
    for root, _, files in os.walk(winrepo_dir):
        for name in files:
            if name.endswith('.sls'):
                try:
                    config = salt.template.compile_template(
                            os.path.join(root, name),
                            renderers,
                            opts['renderer'])
                except SaltRenderError as exc:
                    log.debug(
                        'Failed to render {0}.'.format(
                            os.path.join(root, name)
                        )
                    )
                    log.debug('Error: {0}.'.format(exc))
                    continue
                if config:
                    revmap = {}
                    for pkgname, versions in six.iteritems(config):
                        log.debug(
                            'Compiling winrepo data for package \'{0}\''
                            .format(pkgname)
                        )
                        for version, repodata in six.iteritems(versions):
                            log.debug(
                                'Compiling winrepo data for {0} version {1}'
                                .format(pkgname, version)
                            )
                            if not isinstance(version, six.string_types):
                                config[pkgname][str(version)] = \
                                    config[pkgname].pop(version)
                            if not isinstance(repodata, dict):
                                log.debug(
                                    'Failed to compile {0}.'.format(
                                        os.path.join(root, name)
                                    )
                                )
                                if fire_event:
                                    msg = 'Failed to compile {0}.'.format(
                                        os.path.join(root, name)
                                    )
                                    try:
                                        __jid_event__.fire_event(
                                            {'error': msg},
                                            'progress'
                                        )
                                    except NameError:
                                        log.error(
                                            'Attempted to fire the an event '
                                            'with the following error, but '
                                            'event firing is not supported: '
                                            '{0}'.format(msg)
                                        )
                                continue
                            revmap[repodata['full_name']] = pkgname
                    ret.setdefault('repo', {}).update(config)
                    ret.setdefault('name_map', {}).update(revmap)
    with salt.utils.fopen(
            os.path.join(winrepo_dir, winrepo_cachefile), 'w+b') as repo:
        repo.write(msgpack.dumps(ret))
    return ret
dataset/ETHPy150Open saltstack/salt/salt/runners/winrepo.py/genrepo/swapped operands of `in`