def _filterByFlavorQuery(self, versionFlavorDict, flavorQuery,
                             filterOptions, scoreCache):
        flavorFilter = filterOptions.flavorFilter
        latestFilter = filterOptions.latestFilter
        flavorCheck  = filterOptions.flavorCheck
        if latestFilter == _GET_TROVE_VERY_LATEST:
            versionFlavorList = sorted(versionFlavorDict.iteritems(),
                                       reverse=True)
        else:
            versionFlavorList = list(versionFlavorDict.items())
        if flavorFilter == _GET_TROVE_ALL_FLAVORS and flavorQuery is not None:
            flavorFilter = _GET_TROVE_ALLOWED_FLAVOR

        if flavorFilter == _GET_TROVE_ALL_FLAVORS or flavorQuery is None:
            results = {}
            if latestFilter == _GET_TROVE_VERY_LATEST:
                usedFlavors = set()
                for version, flavorList in versionFlavorList:
                    for flavor in flavorList:
                        if flavor in usedFlavors:
                            continue
                        usedFlavors.add(flavor)
                        results.setdefault(version, set()).add(flavor)
                del usedFlavors
            else:
                for version, flavorList in versionFlavorList:
                    fSet = results.setdefault(version, set())
                    fSet.update(flavorList)
            # no flavor alternatives, we're getting all flavors
            return results, []
        flavorPreferenceList = self._flavorPreferences

        newerEmptyMatches = []
        usedFlavors = set()
        queryResults = {}
        # lower preference score is better, means you've got a
        # flavor that matches a flavor preference earlier in the list.

        if isinstance(flavorQuery, (tuple, list)):
            flavorQuery, primaryFlavorQuery = flavorQuery
        else:
            primaryFlavorQuery = None

        if flavorQuery is not None:
            # if the user specifies something like [is:x86 x86_64]
            # in their query, that should trigger an override of their
            # default flavor preferences to match those in deps/arch.py.
            newPreferenceList = arch.getFlavorPreferencesFromFlavor(
                                                                flavorQuery)
            if newPreferenceList:
                # of course, if they just specified [ssl] then we don't
                # match a preference list and so we don't override
                # the current one.
                flavorPreferenceList = newPreferenceList
        if flavorFilter == _GET_TROVE_ALLOWED_FLAVOR:
            flavorPreferenceList = []

        currentPreferenceScore = len(flavorPreferenceList) + 1

        for version, flavorList in versionFlavorList:
            if primaryFlavorQuery is not None:
                self._calculateFlavorScores(_CHECK_TROVE_STRONG_FLAVOR,
                                            primaryFlavorQuery,
                                            flavorList, scoreCache)
                flavorList = [ x for x in flavorList
                       if scoreCache[primaryFlavorQuery, x] is not False ]
            if not flavorList:
                continue
            self._calculateFlavorScores(flavorCheck, flavorQuery,
                                        flavorList, scoreCache)
            flavorList = [ x for x in flavorList
                           if scoreCache[flavorQuery, x] is not False ]

            if not flavorList:
                continue

            preferenceScore, flavorList, emptyMatches = \
                                            self._filterByPreferences(
                                                    flavorList,
                                                    currentPreferenceScore,
                                                    flavorPreferenceList)
            if preferenceScore is None:
                # didn't find any results better/equal to the current
                # preference score
                continue
            elif (flavorFilter == _GET_TROVE_BEST_FLAVOR
                  and latestFilter == _GET_TROVE_VERY_LATEST
                  and preferenceScore == currentPreferenceScore
                  and queryResults):
                # we match all flavors associated w/ one version
                # at the same time.  So if we're trying to grab the
                # latest viable troves, and we've already got a
                # preference score of 2 for some later version,
                # there's no point finding earlier versions that
                # also have a preference score of 2, since they'll
                # be filtered out by the requirement to have the latest
                # version.
                continue
            elif preferenceScore < currentPreferenceScore:
                currentPreferenceScore = preferenceScore
                # We matched something that was preferred according
                # to the flavorPreference list, for example,
                # if our preferenceList is "is: x86", "ix: x86_64",
                # adn we just matched an older x86_64 trove when we'd
                # already matched a newer x86 trove.  In that case,
                # throw out the x86 trove - it's no longer a valid result.
                queryResults = {}
                usedFlavors = set()
                for emptyVersion, emptyFlavorList in newerEmptyMatches:
                    self._addFilteredFlavorsToResults(emptyVersion,
                                emptyFlavorList, flavorQuery, usedFlavors,
                                queryResults, latestFilter,
                                flavorFilter, scoreCache)
                if latestFilter != _GET_TROVE_VERY_LATEST or not newerEmptyMatches:
                    self._addFilteredFlavorsToResults(version, flavorList,
                                flavorQuery, usedFlavors, queryResults,
                                latestFilter, flavorFilter, scoreCache)
            else:
                self._addFilteredFlavorsToResults(version, flavorList,
                                                  flavorQuery,
                                                  usedFlavors, queryResults,
                                                  latestFilter,
                                                  flavorFilter, scoreCache)

            if emptyMatches:
                if latestFilter == _GET_TROVE_VERY_LATEST:
                    if not newerEmptyMatches:
                        newerEmptyMatches = [(version, emptyMatches)]
                else:
                    newerEmptyMatches.append((version, emptyMatches))


            if (currentPreferenceScore == 0
                and latestFilter == _GET_TROVE_VERY_LATEST
                and flavorFilter == _GET_TROVE_BEST_FLAVOR):
                break
        if not queryResults:
            altFlavors = list(
                            itertools.chain(*[x[1] for x in versionFlavorList]))
        else:
            altFlavors = []
        results = {}
        for version, flavorList in queryResults.iteritems():
            results.setdefault(version, set()).update(flavorList)
        return results, altFlavors
Runs init function::
dataset/ETHPy150Open sassoftware/conary/conary/repository/trovesource.py/SearchableTroveSource._filterByFlavorQuery--crossover with--dataset/ETHPy150Open SmartTeleMax/iktomi/iktomi/cli/sqla.py/Sqla.command_init