\
        Get all the first choices listed from best match to worst match,
        optionally grouping on equal matches.

        :param target:
        :param choices:
        :param group:
501521
def best_matches(self, target, choices):
        

        all = self.all_matches

        try:
            matches = next(all(target, choices, group=True))
            for match in matches:
                yield match
        except StopIteration:
            pass
413545
def choices(cls):
        
        # "natural" order, aka as given when instantiating
        if not hasattr(cls, '__choices_'):
            cls.__choices_ = tuple([c.choice for c in list(cls)])
        return cls.__choices_
395604
def choices(self):
        
        if isinstance(self._choices, Promise):
            self._choices = list(self._choices)
        return self._choices
636517
def _get_choices(self, gandi):
        
        image_list = []
        for item in gandi.image.list():
            label = item['label']
            if item['visibility'] == 'deprecated':
                label = '*%s' % label
            image_list.append(label)
        disk_list = [item['name'] for item in gandi.disk.list_create()]
        return sorted(tuple(set(image_list))) + disk_list
90198
def findFirstHref(link_attrs_list, target_rel):
    """"""
    # XXX: TESTME
    matches = findLinksRel(link_attrs_list, target_rel)
    if not matches:
        return None
    first = matches[0]
    return first.get('href')
208197
def get_matches(self, src, src_idx):
        
        if src not in ('l1', 'l2'):
            raise ValueError('Must have one of "l1" or "l2" as src')
        if src == 'l1':
            target_list = self.l2
        else:
            target_list = self.l1
        comparator = {
            'l1': lambda s_idx, t_idx: (s_idx, t_idx) in self.matches,
            'l2': lambda s_idx, t_idx: (t_idx, s_idx) in self.matches,
        }[src]

        return [(trg_idx, obj) for trg_idx, obj in enumerate(target_list)
                if comparator(src_idx, trg_idx)]
354223
def choice(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
        
        chosen_entry = None

        for i, entry in enumerate(self.find_all(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves)):
            if chosen_entry is None or random.randint(0, i) == i:
                chosen_entry = entry

        if chosen_entry is None:
            raise IndexError()

        return chosen_entry
330026
def findAllByRow(self, target):
        
        row_matches = []
        for row_index in range(self._raster[0]):
            row = self.getRow(row_index)
            row_matches[row_index] = row.findAll(target)
        return row_matches
326188
protected static function paginateGroupChoices(array $choices, $startTo, $endTo)
    {
        $paginatedChoices = [];
        $index = 0;

        foreach ($choices as $groupName => $groupChoices) {
            foreach ($groupChoices as $key => $choice) {
                if ($index >= $startTo && $index < $endTo) {
                    $paginatedChoices[$groupName][$key] = $choice;
                }

                ++$index;
            }
        }

        return $paginatedChoices;
    }
1346834
def best_match_from_list(item,options,fuzzy=90,fname_match=True,fuzzy_fragment=None,guess=False):
    ''''''
    matches = matches_from_list(item,options,fuzzy,fname_match,fuzzy_fragment,guess)
    if len(matches)>0:
        return matches[0]
    return None
986448
public List<String> getMatchedListByGroup(String targetString) {
        return getMatcherAsOpt(targetString)
                .map(matcher -> rangeClosed(1, matcher.groupCount())
                        .mapToObj(matcher::group).map(Object::toString)
                        .collect(toList())).orElseGet(Collections::emptyList);
    }
316223
def _get_choices(self, gandi):
        
        packages = super(CertificatePackageMax, self)._get_choices(gandi)
        ret = list(set([pack.split('_')[2] for pack in packages]))
        if 'w' in ret:
            ret.remove('w')
        return ret
761595
def choices(self):
        
        if isinstance(self.validator, list):
            return self.validator[0].print_choices()
        return self.validator.print_choices()
38800
def optgroups(self, name, value, attrs=None):
        """"""
        default = (None, [], 0)
        groups = [default]
        # We must add at least one 'selected' option or widget will show nothing.
        for v in value:
            if not v:
                continue
            if hasattr(self.choices, 'queryset'):
                item = self.choices.queryset.filter(id=v).first()
                if item:
                    label = item.name
                else:
                    label = force_text(v)
            else:
                label = force_text(v)
            subgroup = default[1]
            subgroup.append(self.create_option(
                name, v, label, True, 0,
                subindex=None, attrs=attrs,
            ))
        return groups
1250137
def _choices(self):
        
        # Generate key/value strings
        pairs = []
        for key, value in self.choices.items():
            pairs.append(str(value) + "=" + str(key))

        # Assemble into overall string and escape
        return GPTaskSpec.manifest_escape(";".join(pairs))
371348
def sort_top_targets(self, top, orders):
        '''
        
        '''
        sorted_top = collections.defaultdict(OrderedDict)
        # pylint: disable=cell-var-from-loop
        for saltenv, targets in six.iteritems(top):
            sorted_targets = sorted(targets,
                    key=lambda target: orders[saltenv][target])
            for target in sorted_targets:
                sorted_top[saltenv][target] = targets[target]
        # pylint: enable=cell-var-from-loop
        return sorted_top
1264304
def _get_choices(self, gandi):
        
        iso_codes = []
        dc_codes = []
        for item in gandi.datacenter.list():
            iso_codes.append(item['iso'])
            if item.get('dc_code'):
                dc_codes.append(item['dc_code'])
        return dc_codes + iso_codes