Return the human readable representation for a list of choices.
    
    @see https://docs.djangoproject.com/en/dev/ref/models/fields/#choices
179745
def ChoiceHumanReadable(choices, choice):
    
    if choice == None: raise NoChoiceError()
    for _choice in choices:
        if _choice[0] == choice:
            return _choice[1]
    raise NoChoiceMatchError("The choice '%s' does not exist in '%s'" % (choice, ", ".join([choice[0] for choice in choices])))
1326223
public function getChoiceFields()
    {
        $choices = parent::getChoiceFields();

        // Shift all extended fields into the "lead" object.
        $resort = false;
        foreach (['extendedField', 'extendedFieldSecure'] as $key) {
            if (isset($choices[$key])) {
                foreach ($choices[$key] as $fieldAlias => $field) {
                    $choices['lead'][$fieldAlias] = $field;
                    unset($choices[$key][$fieldAlias]);
                }
                unset($choices[$key]);
                $resort = true;
            }
        }
        // Sort after we included extended fields (same as core).
        if ($resort) {
            foreach ($choices as $key => $choice) {
                $cmp = function ($a, $b) {
                    return strcmp($a['label'], $b['label']);
                };
                uasort($choice, $cmp);
                $choices[$key] = $choice;
            }
        }

        return $choices;
    }
614399
def choices
      retVal = Array.new 
      if ['yes-no', 'acceptance'].include?(self.style)
        return [["Yes",1],["No",0]]
      elsif !source.blank?
    	  begin
          doc = XML::Document.file(source)
          options = doc.find(text_xpath).collect { |n| n.content }
          values = doc.find(value_xpath).collect { |n| n.content }
          retVal = [options, values].transpose
        rescue NameError
          doc = REXML::Document.new Net::HTTP.get_response(URI.parse(source)).body
          retVal = [ doc.elements.collect(text_xpath){|c|c.text}, doc.elements.collect(value_xpath){|c|c.text} ].transpose.sort
        end
      elsif !content.nil?
        content.split("\n").each do |opt|
          pair = opt.strip.split(";").reverse!
          pair[1] ||= pair[0]
          retVal << pair
        end
      end
      return retVal
    end
1194081
def clone(self, choices):
        
        return self.__class__(
            self.name,
            choices,
            self.label,
            self.description,
            self.multiple,
            self.viewFactory)
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
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
395604
def choices(self):
        
        if isinstance(self._choices, Promise):
            self._choices = list(self._choices)
        return self._choices
889381
def typed_choice(name, choices = [], options = {})
      field name, TypedChoiceField.new(choices, options)
    end
996055
def make_supported_services_choices(self, referencesample):
        
        choices = []
        assigned_services = self.get_assigned_services_uids()
        for uid in self.get_supported_services_uids(referencesample):
            service = api.get_object(uid)
            title = api.get_title(service)
            selected = uid in assigned_services
            choices.append({
                "ResultValue": uid,
                "ResultText": title,
                "selected": selected,
            })
        return choices
1099495
def get_all_choices(cls, *args, **kwargs):
        
        plugins = cls.get_plugins(*args, **kwargs)
        all_choices = reduce(operator.add, [
            plugin.choices for plugin in plugins
        ])
        choices = []
        seen = set()
        for template, label in all_choices:
            # De-duplicate.
            if template in seen:
                continue
            seen.add(template)
            # Validate.
            try:
                validators.template_name(template)
            except ValidationError:
                continue
            choices.append((template, label))
        # Sort by label.
        choices = sorted(choices, key=lambda a: (a[0], a[1]))
        return choices
915705
def choices
      extracted_choices = []

      unless self.qp_answers.nil?
        self.qp_answers.each do |choice|   
          extracted_choices.push(Choice.new(choice))
        end           
      end

      return extracted_choices        
    end
1069505
def get_formfield(model, field):
    
    class_field = model._meta.get_field(field)

    if hasattr(class_field, "field"):
        formfield = class_field.field.formfield()
    else:
        formfield = class_field.formfield()
    
    # Otherwise the formfield contain the reverse relation
    if isinstance(formfield, ChoiceField):
        formfield.choices = class_field.get_choices()
    
    return formfield
500095
def getFieldChoices(dbid,fieldName=nil,fid=nil)
      getSchema(dbid)
      if fieldName
         fid = lookupFieldIDByName(fieldName)
      elsif not fid
         raise "'fieldName' or 'fid' must be specified"
      end
      field = lookupField( fid )
      if field
         choices = []
         choicesProc = proc { |element|
            if element.is_a?(REXML::Element)
               if element.name == "choice" and element.has_text?
                  choices << element.text
               end
            end
         }
         processChildElements(field,true,choicesProc)
         choices = nil if choices.length == 0
         choices
      else   
         nil
      end
   end
250667
function () {
		
			var choiceIndex;
			
			if (this.el.selectedIndex >= 0) {
				
				choiceIndex = inputEx.indexOf(this.el.childNodes[this.el.selectedIndex], this.choicesList, function (node, choice) {
					return node === choice.node;
				});
			
				return this.choicesList[choiceIndex].value;
				
			} else {
				
				return "";
				
			}
		}
797420
def get_child_type_choices(self, request, action):
        
        # Get choices from the super class to check permissions.
        choices = super(ChildModelPluginPolymorphicParentModelAdmin, self) \
            .get_child_type_choices(request, action)
        # Update label with verbose name from plugins.
        plugins = self.child_model_plugin_class.get_plugins()
        labels = {}
        sort_priorities = {}

        if plugins:
            for plugin in plugins:
                pk = plugin.content_type.pk
                labels[pk] = capfirst(plugin.verbose_name)
                sort_priorities[pk] = getattr(plugin, 'sort_priority', labels[pk])

            choices = [(ctype, labels[ctype]) for ctype, _ in choices]
            return sorted(choices,
                cmp=lambda a, b: cmp(
                    sort_priorities[a[0]],
                    sort_priorities[b[0]]
                )
            )

        return choices
298705
def choicify(dictionary):
    
    # get order of the fields
    ordered_fields = sorted(dictionary, key=dictionary.get)
    choices = []
    # loop over each field
    for field in ordered_fields:
        # build tuple (value, i18n_key)
        row = (dictionary[field], _(field.replace('_', ' ')))
        # append tuple to choices
        choices.append(row)
    # return django sorted choices
    return choices
145256
protected function getIterativeUserSelectionModeChoices()
    {
        $choices = [];

        foreach ($this->context->output['models'] as $id => $model) {
            if (in_array($id, $this->modelsDone)) continue;

            $choices[] = $id . ': ' . $model['name'];
        }

        ksort($choices);

        return $choices;
    }