Formatted string to display the available choices
421942
def info(self):
        """"""
        if self.descriptions is None:
            choice_list = ['"{}"'.format(choice) for choice in self.choices]
        else:
            choice_list = [
                '"{}" ({})'.format(choice, self.descriptions[choice])
                for choice in self.choices
            ]
        if len(self.choices) == 2:
            return 'either {} or {}'.format(choice_list[0], choice_list[1])
        return 'any of {}'.format(', '.join(choice_list))
1257200
def displayformat(codes=[], fg=None, bg=None):
        """"""
        if isinstance(codes, basestring):
            codes = [codes]
        else:
            codes = list(codes)
        for code in codes:
            if code not in Magic.DISPLAY.keys():
                raise ValueError("'%s' not a valid display value" % code)
        for color in (fg, bg):
            if color != None:
                if color not in Magic.COLORS.keys():
                    raise ValueError("'%s' not a valid color" % color)
        return [codes, fg, bg]
921701
def format_options(options):
    ''''''
    # split on one of the following tokens: ' -' or '[[' or ']]'
    lines = ['']
    for token in re.split(r'( -|\[\[|\]\])', options):
        if token in ['[[',']]']:
            lines.append(token)
            lines.append('')
        elif token == ' -':
            lines.append(token)
        else:
            lines[-1] += token
    # join all non-empty lines and wrap them into 'span'-tags
    return '<span style="display:block">' + '</span><span style="display:block">'.join(line for line in lines if line.strip()) + '</span>'
1065921
public function choose($string, array $choices, $useChoiceKeysAsSelector = true) {
        $this->output->writeLine("<question>$string</question>");

        $choicesMap = [];

        foreach ($choices as $subject => $message) {
            if ($useChoiceKeysAsSelector) {
                $index = $subject;
            } else {
                $index = count($choicesMap) + 1;
            }

            $choicesMap[$index] = [
                'subject' => $subject,
                'message' => $message,
            ];
        }

        foreach ($choicesMap as $index => $choice) {
            $message = array_get($choice, 'message');

            $this->output->writeLineIndented("[<yellow>$index</yellow>] $message");
        }

        $choice = null;

        while (true) {
            $this->output->writeIndented('Choice: ');
            $input = $this->input->readLine();

            if (array_has($choicesMap, $input)) {
                $choice = array_get(array_get($choicesMap, $input), 'subject');
                break;
            }

            if ( ! empty($input)) {
                $this->output->writeLineIndented('<yellow>Invalid choice</yellow>');
            }
        }

        return $choice;
    }
243299
def _str(self, indent=""):
        """"""
        if self.ndim <= 1:
            return "[" + ", ".join(str(x) for x in self) + "]"
        elif self.ndim == 2:
            sep = ",\n" + indent
            return "[" + sep.join(x._str(indent + " ") for x in self) + "]"
        else:
            sep = ",\n\n" + indent
            return "[" + sep.join(x._str(indent + " ") for x in self) + "]"
1155152
def value_str(sc):
    
    if sc.type in (STRING, INT, HEX):
        return "({})".format(sc.str_value)

    # BOOL or TRISTATE

    # The choice mode is an upper bound on the visibility of choice symbols, so
    # we can check the choice symbols' own visibility to see if the choice is
    # in y mode
    if isinstance(sc, Symbol) and sc.choice and sc.visibility == 2:
        # For choices in y mode, print '-->' next to the selected symbol
        return "-->" if sc.choice.selection is sc else "   "

    tri_val_str = (" ", "M", "*")[sc.tri_value]

    if len(sc.assignable) == 1:
        # Pinned to a single value
        return "-{}-".format(tri_val_str)

    if sc.type == BOOL:
        return "[{}]".format(tri_val_str)

    if sc.type == TRISTATE:
        if sc.assignable == (1, 2):
            # m and y available
            return "{" + tri_val_str + "}"  # Gets a bit confusing with .format()
        return "<{}>".format(tri_val_str)
1084342
function renderChoices(choices, pointer) {
  var output = '';

  choices.forEach(function(choice, i) {
    output += '\n  ';

    if (choice.type === 'separator') {
      output += ' ' + choice;
      return;
    }

    var choiceStr = choice.key + ') ' + choice.name;
    if (pointer === choice.key) {
      choiceStr = utils.chalk.cyan(choiceStr);
    }
    output += choiceStr;
  });

  return output;
}
1119600
def _get_option_list(options):
    '''
    
    '''
    return ', '.join(['{0}={1}'.format(x, y) for x, y in six.iteritems(options)])
1326508
def get_choices(cls, category):
        """"""
        value = cls._DEFAULTS[category]
        if not isinstance(value, list):
            raise ValueError("{} does not offer choices".format(category))
        return value
849312
def choices(self):
        """"""
        if self._choices:
            return self._choices
        for n in os.listdir(self._voicedir):
            if len(n) == 1 and os.path.isdir(os.path.join(self._voicedir, n)):
                self._choices.append(n)
        return self._choices
18599
def get_select_options(self):
        
        if self.filter_choices:
            return [choice[:4] for choice in self.filter_choices
                    # Display it If the fifth element is True or does not exist
                    if len(choice) < 5 or choice[4]]
838083
def choose(items, title_text, question_text):
    
    print(title_text)

    for i, item in enumerate(items, start=1):
        print('%d) %s' % (i, item))
    print('%d) Abort' % (i + 1))

    selected = input(question_text)
    try:
        index = int(selected)
    except ValueError:
        index = -1
    if not (index - 1) in range(len(items)):
        print('Aborting.')
        return None

    return items[index - 1]
78525
def enum_choice_list(data):
    

    # transform enum types, otherwise assume list of string choices
    if not data:
        return {}
    try:
        choices = [x.value for x in data]
    except AttributeError:
        choices = data

    def _type(value):
        return next((x for x in choices if x.lower() == value.lower()), value) if value else value
    params = {
        'choices': CaseInsensitiveList(choices),
        'type': _type
    }
    return params
1349821
def choices(self):
        
        choice_list = getattr(
            settings, 'MARKUP_CHOICES', DEFAULT_MARKUP_CHOICES
        )
        return [(f, self._get_filter_title(f)) for f in choice_list]
999613
function getChoices() {
  const name = choice => fp.padStart(MAX_DESC)(choice.value)
  const desc = choice => wrap(choice.description, MAX)
  return types.map(choice => {
    if (choice.value === 'separator') return SEPARATOR
    return {
      name: `${name(choice)}  ${choice.emoji}  ${desc(choice)}`,
      value: choice.value,
      short: name(choice)
    }
  })
}
211973
def _convert_choices(self, choices):
        """"""

        final_choices = []
        for choice in choices:

            if isinstance(choice, ChoiceEntry):
                final_choices.append(choice)
                continue

            original_choice = choice
            if isinstance(choice, six.string_types):
                if choice == _NO_SUBSET_NAME_:
                    continue
                choice = [choice, ]
            else:
                choice = list(choice)

            length = len(choice)

            assert 1 <= length <= 4, 'Invalid number of entries in %s' % (original_choice,)

            final_choice = []

            # do we have attributes?
            if length > 1 and isinstance(choice[-1], Mapping):
                final_choice.append(choice.pop())
            elif length == 4:
                attributes = choice.pop()
                assert attributes is None or isinstance(attributes, Mapping), 'Last argument must be a dict-like object in %s' % (original_choice,)
                if attributes:
                    final_choice.append(attributes)

            # the constant
            final_choice.insert(0, choice.pop(0))

            if len(choice):
                # we were given a db value
                final_choice.insert(1, choice.pop(0))
                if len(choice):
                    # we were given a display value
                    final_choice.insert(2, choice.pop(0))
            else:
                # set None to compute it later
                final_choice.insert(1, None)

            if final_choice[1] is None:
                # no db value, we compute it from the constant
                final_choice[1] = self.value_transform(final_choice[0])

            final_choices.append(final_choice)

        return super(AutoChoices, self)._convert_choices(final_choices)
1133135
def make_position_choices(self):
        
        choices = []
        for pos in self.get_available_positions():
            choices.append({
                "ResultValue": pos,
                "ResultText": pos,
            })
        return choices