Autocomplete for format option
424112
def complete_opt_format(self, text, *_):
        
        return [t + " " for t in FORMATTERS if t.startswith(text)]
407916
private function __autocomplete($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'name'     => '',
            'attribs'  => array(
                'id' => 'select2-element-'.mt_rand(1000, 100000)
            ),
            'validate' => true,
            'prompt'   => '- '.$this->getObject('translator')->translate('Select').' -',
            'deselect' => true,
        ))->append(array(
            'element'    => '#'.$config->attribs->id,
            'options'    => array('multiple' => (bool) $config->attribs->multiple),
            'value'      => $config->name,
            'selected'   => $config->{$config->name},
        ))->append(array(
            'label'      => $config->value,
        ))->append(array(
            'text'       => $config->label,
            'filter'     => array('sort' => $config->label),
        ));

        if (!$config->ajax_url)
        {
            $identifier = $config->model->getIdentifier();
            $parts      = array(
                'component' => $identifier->package,
                'view'      => $identifier->name,
                'format'    => 'json'
            );

            if ($config->filter) {
                $parts = array_merge($parts, ObjectConfig::unbox($config->filter));
            }

            $config->ajax_url = $this->getObject('lib:dispatcher.router.route')->setQuery($parts);
        }

        $html = '';
        $html .= $this->createHelper('behavior')->autocomplete($config);

        $config->attribs->name = $config->name;

        $options = array();

        if ((is_scalar($config->selected) && $config->selected) || count($config->selected))
        {
            $selected = $config->selected;

            if(!$selected instanceof ModelEntityInterface)
            {
                $selected = $config->model
                    ->setState(ObjectConfig::unbox($config->filter))
                    ->setState(array($config->value => ObjectConfig::unbox($selected)))
                    ->fetch();
            }

            foreach($selected as $entity)
            {
                $options[]  = $this->option(array(
                    'value' => $entity->{$config->value},
                    'label' => $entity->{$config->label},
                    'attribs' => array('selected' => true)
                ));
            }
        }

         $html .= $this->optionlist(array(
            'name'     => $config->name,
            'id'       => $config->id,
            'options' => $options,
            'deselect' => false,
            'select2'  => false,
            'attribs'  => $config->attribs
        ));

        return $html;
    }
747224
def get_choices(cli, prog_name, args, incomplete):
    
    all_args = copy.deepcopy(args)

    ctx = resolve_ctx(cli, prog_name, args)
    if ctx is None:
        return []

    # In newer versions of bash long opts with '='s are partitioned, but it's easier to parse
    # without the '='
    if start_of_option(incomplete) and WORDBREAK in incomplete:
        partition_incomplete = incomplete.partition(WORDBREAK)
        all_args.append(partition_incomplete[0])
        incomplete = partition_incomplete[2]
    elif incomplete == WORDBREAK:
        incomplete = ''

    completions = []
    if start_of_option(incomplete):
        # completions for partial options
        for param in ctx.command.params:
            if isinstance(param, Option) and not param.hidden:
                param_opts = [param_opt for param_opt in param.opts +
                              param.secondary_opts if param_opt not in all_args or param.multiple]
                completions.extend([(o, param.help) for o in param_opts if o.startswith(incomplete)])
        return completions
    # completion for option values from user supplied values
    for param in ctx.command.params:
        if is_incomplete_option(all_args, param):
            return get_user_autocompletions(ctx, all_args, incomplete, param)
    # completion for argument values from user supplied values
    for param in ctx.command.params:
        if is_incomplete_argument(ctx.params, param):
            return get_user_autocompletions(ctx, all_args, incomplete, param)

    add_subcommand_completions(ctx, incomplete, completions)
    # Sort before returning so that proper ordering can be enforced in custom types.
    return sorted(completions)
939709
def _autocomplete(client, url_part, input_text, session_token=None,
                  offset=None, location=None, radius=None, language=None,
                  types=None, components=None, strict_bounds=False):
    

    params = {"input": input_text}

    if session_token:
        params["sessiontoken"] = session_token
    if offset:
        params["offset"] = offset
    if location:
        params["location"] = convert.latlng(location)
    if radius:
        params["radius"] = radius
    if language:
        params["language"] = language
    if types:
        params["types"] = types
    if components:
        if len(components) != 1 or list(components.keys())[0] != "country":
            raise ValueError("Only country components are supported")
        params["components"] = convert.components(components)
    if strict_bounds:
        params["strictbounds"] = "true"

    url = "/maps/api/place/%sautocomplete/json" % url_part
    return client._request(url, params).get("predictions", [])
267187
def autocomplete(self, line):
        """"""
        current_length = len(line)
        self._current_line = line
        if current_length == 1 and self._last_position > 1:
            # Reset state.  This is likely from a user completing
            # a previous command.
            self.reset()
        elif current_length < self._last_position:
            # The user has hit backspace.  We'll need to check
            # the current words.
            return self._handle_backspace()
        elif not line:
            return []
        elif current_length != self._last_position + 1:
            return self._complete_from_full_parse()

        # This position is important.  We only update the _last_position
        # after we've checked the special cases above where that value
        # matters.
        self._last_position = len(line)
        if line and not line.strip():
            # Special case, the user hits a space on a new line so
            # we autocomplete all the top level commands.
            return self._current['commands']

        last_word = line.split()[-1]
        if last_word in self.arg_metadata or last_word in self._global_options:
            # The last thing we completed was an argument, record
            # this as self.last_arg
            self.last_option = last_word
        if line[-1] == ' ':
            # At this point the user has autocompleted a command
            # or an argument and has hit space.  If they've
            # just completed a command, we need to change the
            # current context and traverse into the subcommand.
            # "ec2 "
            #      ^--here, need to traverse into "ec2"
            #
            # Otherwise:
            # "ec2 --no-validate-ssl "
            #                        ^-- here, stay on "ec2" context.
            if not last_word.startswith('-'):
                next_command = self._current['children'].get(last_word)
                if next_command is not None:
                    self._current = next_command
                    self._current_name = last_word
                    self.cmd_path.append(self._current_name)
            elif last_word in self.arg_metadata and \
                    self.arg_metadata[last_word]['example']:
                # Then this is an arg with a shorthand example so we'll
                # suggest that example.
                return [self.arg_metadata[last_word]['example']]
            # Even if we don't change context, we still want to
            # autocomplete all the commands for the current context
            # in either of the above two cases.
            return self._current['commands'][:]
        elif last_word.startswith('-'):
            # TODO: cache this for the duration of the current context.
            # We don't need to recompute this until the args are
            # different.
            all_args = self._get_all_args()
            if self.match_fuzzy:
                return fuzzy_search(last_word, all_args)
            else:
                return substring_search(last_word, all_args)
        if self.match_fuzzy:
            return fuzzy_search(last_word, self._current['commands'])
        else:
            return substring_search(last_word, self._current['commands'])
1349690
def _format_option(opt):
    """"""
    opt = _get_help_record(opt)

    yield '.. option:: {}'.format(opt[0])
    if opt[1]:
        yield ''
        for line in statemachine.string2lines(
                opt[1], tab_width=4, convert_whitespace=True):
            yield _indent(line)
1319493
public AutoComplete autoCompleteCommand(String prefix) {
        final Trie<CliValueType> possibilities = childCommands.subTrie(prefix).mapValues(CliValueType.COMMAND.<CliCommand>getMapper());
        return new AutoComplete(prefix, possibilities);
    }
565007
public function autocomplete() {
        $tree = Globals::getTree();
        $controller = new JsonController();
        
        $city = Filter::get('city');
        $contains = Filter::get('term');        

        $controller
            ->restrictAccess(Auth::isEditor($tree) && !empty($city) && !empty($contains))
            ->pageHeader();
        
        $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); 
        $controller->encode($listCert);
    }
117686
function linkAutoComplete() {
    return listFiles('autocomplete')
        .then(filter(endsWith('.js')) & map(path.join('autocomplete', _)))
        .tap(files => all(files.map(file => fs.readFileAsync(file)
            .then(ensureNoImports(file)))));
}
967830
function getMatch(ctx, data, options) {
  // Look for a command match, eliminating and then
  // re-introducing leading spaces.
  var len = ctx.length;
  var trimmed = ctx.replace(/^\s+/g, '');
  var match = autocomplete.match(trimmed, data.slice(), options);
  if (_.isArray(match)) {
    return match;
  }
  var prefix = new Array(len - trimmed.length + 1).join(' ');
  // If we get an autocomplete match on a command, finish it.
  if (match) {
    // Put the leading spaces back in.
    match = prefix + match;
    return match;
  }
  return undefined;
}
491236
function getMarkupSnippetsCompletions(editor, prefix) {
	const syntax = detectSyntax(editor);

	if (!completionsCache.has(syntax)) {
		// Create cache with Emmet snippets completions
		const registry = createSnippetsRegistry(syntax);
		const field = (index, placeholder) => placeholder || '';
		const completions = registry.all({type: 'string'}).map(snippet => ({
			text: snippet.key,
			type: 'snippet',
			rightLabel: expandAbbreviation(snippet.value, editor, { syntax, field })
		}));

		completionsCache.set(syntax, completions);
	}

	let completions = completionsCache.get(syntax);

	if (prefix) {
		completions = completions.filter(completion => completion.text.indexOf(prefix) === 0);
	}

	return completions.map(completion => Object.assign({ replacementPrefix: prefix }, completion));
}
1331782
def format_auto_patching_settings(result):
    '''
    
    '''
    from collections import OrderedDict
    # Only display parameters that have content
    order_dict = OrderedDict()
    if result.enable is not None:
        order_dict['enable'] = result.enable
    if result.day_of_week is not None:
        order_dict['dayOfWeek'] = result.day_of_week
    if result.maintenance_window_starting_hour is not None:
        order_dict['maintenanceWindowStartingHour'] = result.maintenance_window_starting_hour
    if result.maintenance_window_duration is not None:
        order_dict['maintenanceWindowDuration'] = result.maintenance_window_duration

    return order_dict
814250
public function autoComplete($data)
    {
        $inputID = $this->getInputId();
        ArrayHelper::setValue($this->inputOptions, 'list', "$inputID-list");

        $html = Html::beginTag('datalist', ['id' => "$inputID-list"]) . "\n";
        foreach ($data as $item) {
            $html .= Html::tag('option', $item) . "\n";
        }
        $html .= Html::endTag('datalist');

        $this->parts['{list}'] = $html;

        return $this;
    }
859526
def format_type(t, includeOptional=True):
    
    s = ""
    if t.has_key('is_array') and t['is_array']:
        s = "[]%s" % t['type']
    else:
        s = t['type']
    if includeOptional and t.has_key('optional') and t['optional'] == True:
        s += " [optional]"
    return s
1109362
def _autocomplete_default(self, text: str, line: str, begidx: int, endidx: int,
                              argparser: argparse.ArgumentParser) -> List[str]:
        """"""
        completer = AutoCompleter(argparser, self)

        tokens, _ = self.tokens_for_completion(line, begidx, endidx)
        if not tokens:
            return []

        return completer.complete_command(tokens, text, line, begidx, endidx)
890450
def autocomplete(force=False):
    "  "

    if 'MAKESITE_AUTO_COMPLETE' not in environ and not force:
        return

    commands = filter(lambda cmd: cmd != 'main', ACTIONS.keys())

    cwords = environ['COMP_WORDS'].split()[1:]
    cword = int(environ['COMP_CWORD'])

    try:
        current = cwords[cword - 1]
    except IndexError:
        current = ''

    try:
        sub_action = [cmd for cmd in commands if cmd in cwords][0]
        if sub_action in ['info', 'uninstall', 'update', 'template']:
            if settings.MAKESITE_HOME:
                if not current or current.startswith('/'):
                    sites = list(gen_sites(settings.MAKESITE_HOME))
                    print ' '.join(site.deploy_dir for site in sites if site.
                                   deploy_dir.startswith(current))
                else:
                    names = map(lambda s: s.get_name(
                    ), gen_sites(settings.MAKESITE_HOME))
                    print ' '.join(
                        name for name in names if name.startswith(current))
        elif sub_action == 'install' and (cwords[-1] == '-m' or (current and cwords[-2] == '-m')):
            print ' '.join(
                mod for mod in get_base_modules() if mod.startswith(current))
        elif sub_action == 'install' and (cwords[-1] == '-t' or (current and cwords[-2] == '-t')):
            print ' '.join(tpl for tpl in get_base_templates(
            ) if tpl.startswith(current))
        elif sub_action == 'module':
            print ' '.join(
                tpl for tpl in get_base_modules() if tpl.startswith(current))
    except IndexError:
        print (' '.join(a for a in commands if a.startswith(current)))
    sys.exit(1)
827900
def formatted_completion_sig(completion):
    """"""
    f_result = completion["name"]
    if is_basic_type(completion):
        # It's a raw type
        return f_result
    elif len(completion["typeInfo"]["paramSections"]) == 0:
        return f_result

    # It's a function type
    sections = completion["typeInfo"]["paramSections"]
    f_sections = [formatted_param_section(ps) for ps in sections]
    return u"{}{}".format(f_result, "".join(f_sections))