Select the first portlet name by default for the form
964725
protected void selectFormDefaultPortlet(final F report) {
        final Set<AggregatedPortletMapping> portlets = this.getPortlets();
        if (!portlets.isEmpty()) {
            report.getPortlets().add(portlets.iterator().next().getFname());
        }
    }
1345773
def pick_port(self):
        """"""
        ports = set(range(self.min_port, self.min_port + self.port_range))
        return port_for.select_random(ports)
583715
private function setFormName() : void
    {
        $this->key = 'form_' . $this->name . '_' . bin2hex(random_bytes(16));

        // Form key must be unique
        if (isset($_SESSION[$this->key])) {
            $this->setFormName();
        }

        // Remove potential previous form with same name from session
        $prev_form_keys = preg_grep('/^form_' . preg_quote($this->name, '/') . '_[a-f0-9]+$/', array_keys($_SESSION));
        array_map(function ($key) {
            unset($_SESSION[$key]);
        }, $prev_form_keys);

        // Save the new form
        $_SESSION[$this->key] = [];
    }
611701
function maybe_name_with_default() {
  skip_horiz_white();
  if (look(/\[/)) {
    match(/\[/);
    maybe_ident_chain("name");
    skip_horiz_white();
    if (look(/=/)) {
      match(/=/);
      skip_horiz_white();
      current_tag["default"] = default_value();
    }
    skip_horiz_white();
    match(/\]/);
    current_tag["optional"] = true;
  }
  else {
    maybe_ident_chain("name");
  }
}
498932
def get_if_present(self, name, default=None):
        
        if not self.processed_data:
            raise exceptions.FormNotProcessed('The form data has not been processed yet')

        if name in self.field_dict:
            return self[name]

        return default
14623
function getDefaultImportName(node) {
  const defaultSpecifier = node.specifiers
    .find(specifier => specifier.type === 'ImportDefaultSpecifier')
  return defaultSpecifier != null ? defaultSpecifier.local.name : undefined
}
1239304
def setdefault(self, name: str, default: Any=None) -> Any:
        """"""
        return self.__dict__.setdefault(name, default)
1330339
def _get_form(self, config_name, only_required=False):
        """"""
        if getattr(self, config_name, None):
            return import_object_by_string(getattr(self, config_name))

        def use_field(field):
            if not only_required:
                return True
            return field.default == NOT_PROVIDED

        return modelform_factory(self.model, fields=[f.name for f in self.model.get_fields() if use_field(f)])
428845
def get_initial(self):
        '''
        
        '''
        initial = super(SendEmailView, self).get_initial()

        form_data = self.request.session.get(EMAIL_VALIDATION_STR, {}).get('form_data', {})
        if form_data:
            initial.update(form_data)
        return initial
168567
protected function checkIfNamedForm()
    {
        if ($this->getFormOption('name')) {
            $this->name = Arr::pull($this->formOptions, 'name', $this->name);
        }
    }
142837
def select_port(default_port=20128):
    """"""
    import socket
    while True:
        try:
            sock = socket.socket(socket.AF_INET,
                                 socket.SOCK_STREAM,
                                 socket.IPPROTO_TCP)
#            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            sock.bind( ("127.0.0.1", default_port) )
        except socket.error as _msg:  # analysis:ignore
            default_port += 1
        else:
            break
        finally:
            sock.close()
            sock = None
    return default_port
134984
@Override
    public IPortletWindowId getDefaultPortletWindowId(
            HttpServletRequest request, IPortletEntityId portletEntityId) {
        final IPortletWindowId portletWindowId = this.createPortletWindowId(null, portletEntityId);
        logger.trace(
                "Determined default portlet window id {} for portlet entity {}",
                portletWindowId,
                portletEntityId);
        return portletWindowId;
    }
825550
protected function checkIfNamedForm()
    {
        if ($this->getFormOption('name')) {
            $this->name = array_pull($this->formOptions, 'name', $this->name);
        }
    }
230869
protected function initForm()
    {
        (isset($this->options['name'])) ? $name = $this->options['name'] : $name = '';
        if (empty($name)) {
            $name = 'form_' . (count(self::$forms) + 1);
        }
        unset($this->options['name']);

        $this->form = tao_helpers_form_FormFactory::getForm($name, $this->options);

        //add property action in toolbar
        $actions     = tao_helpers_form_FormFactory::getCommonActions();
        $propertyElt = tao_helpers_form_FormFactory::getElement('property', 'Free');
        $propertyElt->setValue(
            "<a href='#' class='btn-info property-adder small'><span class='icon-property-add'></span> " . __('Add property') . "</a>"
        );
        $actions[] = $propertyElt;

        //property mode
        $propModeELt = tao_helpers_form_FormFactory::getElement('propMode', 'Free');
        if($this->propertyMode == 'advanced'){
            $propModeELt->setValue("<a href='#' class='btn-info property-mode small property-mode-simple'><span class='icon-property-advanced'></span> ".__('Simple Mode')."</a>");
        }
        else{
            $propModeELt->setValue("<a href='#' class='btn-info property-mode small property-mode-advanced'><span class='icon-property-advanced'></span> ".__('Advanced Mode')."</a>");
        }

        $actions[] = $propModeELt;

        //add a hidden field that states it is a class edition form.
        $classElt = tao_helpers_form_FormFactory::getElement('tao.forms.class', 'Hidden');
        $classElt->setValue('1');
        $classElt->addClass('global');
        $this->form->addElement($classElt);

        $this->form->setActions($actions, 'top');
        $this->form->setActions($actions, 'bottom');


    }
391117
def set_default_names(data):
    """"""
    if com._all_not_none(*data.index.names):
        nms = data.index.names
        if len(nms) == 1 and data.index.name == 'index':
            warnings.warn("Index name of 'index' is not round-trippable")
        elif len(nms) > 1 and any(x.startswith('level_') for x in nms):
            warnings.warn("Index names beginning with 'level_' are not "
                          "round-trippable")
        return data

    data = data.copy()
    if data.index.nlevels > 1:
        names = [name if name is not None else 'level_{}'.format(i)
                 for i, name in enumerate(data.index.names)]
        data.index.names = names
    else:
        data.index.name = data.index.name or 'index'
    return data
1182410
def get_prefix(self, form, name):
        
        return '{form_prefix}{prefix_name}-{field_name}'.format(
            form_prefix=form.prefix + '-' if form.prefix else '',
            prefix_name=self.prefix_name,
            field_name=name)
1042026
public String getDefaultTableName()
    {
        String name          = getName();
        int    lastDotPos    = name.lastIndexOf('.');
        int    lastDollarPos = name.lastIndexOf('$');

        return lastDollarPos > lastDotPos ? name.substring(lastDollarPos + 1) : name.substring(lastDotPos + 1);
    }