Create min-match dictionary for choice list
976096
def _setChoiceDict(self):
        """"""
        # value is full name of choice parameter
        self.choiceDict = minmatch.MinMatchDict()
        for c in self.choice: self.choiceDict.add(c, c)
922008
def choose(self, prompt, items, default=None):
        
        if default is not None and (default >= len(items) or default < 0):
            raise IndexError
        prompt = prompt if prompt is not None else "Choose from following:"
        self.show(prompt + '\n')
        self.show("\n".join(number(items)))  # show the items
        prompt = "Enter number of chosen item"
        prompt += " [{0}]: ".format(default) if default is not None else ': '
        return items[self.input(
            curry(filter_int, default=default, start=0, stop=len(items)),
            prompt
        )]
1196624
async function requestChoice(message, items) {
  const answerName = 'requestChoice';
  const answers = await inquirer.prompt([
    {
      message,
      name: answerName,
      type: 'list',
      choices: getChoices(items),
    },
  ]);
  return answers[answerName];
}
943334
def multiple_choice(name, choices = [], options = {})
      field name, MultipleChoiceField.new(choices, options)
    end
30024
def choices_validator(choices):
    
    def validator(value):
        if value not in choices:
            # note: make it a list for consistent representation
            raise ValidationError(
                "{} is not in {}".format(value, list(choices))
            )

    return validator
1029276
def suggestion_list(inp, options):
    
    options_by_distance = OrderedDict()
    input_threshold = len(inp) / 2

    for option in options:
        distance = lexical_distance(inp, option)
        threshold = max(input_threshold, len(option) / 2, 1)
        if distance <= threshold:
            options_by_distance[option] = distance

    return sorted(
        list(options_by_distance.keys()), key=lambda k: options_by_distance[k]
    )
1208953
def options(cls):
        """"""
        return {k: v for k, v in cls.__dict__.items() if isinstance(v, Option)}
1029756
def list2dict(list_of_options):
    """"""
    d = {}
    for key, value in list_of_options:
        d[key] = value
    return d
56138
def filter_opt(opt):
    """"""
    return {k: GLib.Variant(*v) for k, v in opt.items() if v[1] is not None}
616014
def _make_opt_list(opts, group):
    
    import copy
    import itertools

    _opts = [(group, list(itertools.chain(*opts)))]
    return [(g, copy.deepcopy(o)) for g, o in _opts]
761595
def choices(self):
        
        if isinstance(self.validator, list):
            return self.validator[0].print_choices()
        return self.validator.print_choices()
251177
def _build_list(option_value, item_kind):
    '''
    
    '''
    #specify profiles if provided
    if option_value is not None:

        items = []

        #if user specified none, return an empty list
        if option_value == 'none':
            return items

        #was a list already passed in?
        if not isinstance(option_value, list):
            values = option_value.split(',')
        else:
            values = option_value

        for value in values:
            # sometimes the bigip just likes a plain ol list of items
            if item_kind is None:
                items.append(value)
            # other times it's picky and likes key value pairs...
            else:
                items.append({'kind': item_kind, 'name': value})
        return items
    return None
436048
def get_choice(prompt, choices):
    
    print()
    checker = []
    for offset, choice in enumerate(choices):
        number = offset + 1
        print("\t{}): '{}'\n".format(number, choice))
        checker.append(str(number))

    response = get_input(prompt, tuple(checker) + ('',))
    if not response:
        print("Exiting...")
        exit()

    offset = int(response) - 1
    selected = choices[offset]

    return selected
1250348
def filter(objects, Type=None, min=-1, max=-1): #PYCHOK muppy filter
    
    res = []
    if min > max:
        raise ValueError("minimum must be smaller than maximum")
    if Type is not None:
        res = [o for o in objects if isinstance(o, Type)]
    if min > -1:
        res = [o for o in res if _getsizeof(o) < min]
    if max > -1:
        res = [o for o in res if _getsizeof(o) > max]
    return res
538992
def find_keyword(word_list: List[str], min_len: int = 3) -> Dict[str, int]:
    
    word_list = rank(word_list, exclude_stopwords=True)

    return {k: v for k, v in word_list.items() if v >= min_len}
1281744
def sample_less_than_condition(choices_in, condition):
    
    output = np.zeros(min(condition.shape[0], choices_in.shape[0]))
    choices = copy.deepcopy(choices_in)
    for i, _ in enumerate(output):
        # randomly select one of the choices which meets condition
        avail_inds = np.where(choices < condition[i])[0]
        selected_ind = np.random.choice(avail_inds)
        output[i] = choices[selected_ind]
        # remove the chosen value
        choices = np.delete(choices, selected_ind)
    return output
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