Installs a formatter that takes the tag options dictionary, puts a value key
        in it, and uses it as a format dictionary to the given format string.
504490
def add_simple_formatter(self, tag_name, format_string, **kwargs):
        
        def _render(name, value, options, parent, context):
            fmt = {}
            if options:
                fmt.update(options)
            fmt.update({'value': value})
            return format_string % fmt
        self.add_formatter(tag_name, _render, **kwargs)
549849
def format(args):
    
    sequential_choices = ("replace", "prefix", "suffix")
    p = OptionParser(format.__doc__)
    p.add_option("--pairs", default=False, action="store_true",
            help="Add trailing /1 and /2 for interleaved pairs [default: %default]")
    p.add_option("--sequential", default=None, choices=sequential_choices,
            help="Add sequential IDs [default: %default]")
    p.add_option("--sequentialoffset", default=0, type="int",
            help="Sequential IDs start at [default: %default]")
    p.add_option("--pad0", default=0, type="int",
            help="Pad a few zeros in front of sequential [default: %default]")
    p.add_option("--gb", default=False, action="store_true",
            help="For Genbank ID, get the accession [default: %default]")
    p.add_option("--sep", default=None,
            help="Split description by certain symbol [default: %default]")
    p.add_option("--index", default=0, type="int",
            help="Extract i-th field after split with --sep [default: %default]")
    p.add_option("--noversion", default=False, action="store_true",
            help="Remove the gb trailing version [default: %default]")
    p.add_option("--prefix", help="Prepend prefix to sequence ID")
    p.add_option("--suffix", help="Append suffix to sequence ID")
    p.add_option("--template", default=False, action="store_true",
            help="Extract `template=aaa dir=x library=m` to `m-aaa/x` [default: %default]")
    p.add_option("--switch", help="Switch ID from two-column file [default: %default]")
    p.add_option("--annotation", help="Add functional annotation from "
                        "two-column file ('ID <--> Annotation') [default: %default]")
    p.add_option("--ids", help="Generate ID conversion table [default: %default]")
    p.add_option("--upper", default=False, action="store_true",
            help="Convert sequence to upper case [default: %default]")
    p.add_option("--nodesc", default=False, action="store_true",
            help="Remove description after identifier")
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    infasta, outfasta = args
    gb = opts.gb
    pairs = opts.pairs
    prefix = opts.prefix
    suffix = opts.suffix
    noversion = opts.noversion
    sequential = opts.sequential
    sequentialoffset = opts.sequentialoffset
    sep = opts.sep
    idx = opts.index
    mapfile = opts.switch
    annotfile = opts.annotation
    desc = not opts.nodesc
    idsfile = opts.ids
    idsfile = open(idsfile, "w") if idsfile else None
    upper = opts.upper

    if mapfile:
        mapping = DictFile(mapfile, delimiter="\t")
    if annotfile:
        annotation = DictFile(annotfile, delimiter="\t")

    fp = SeqIO.parse(must_open(infasta), "fasta")
    fw = must_open(outfasta, "w")
    for i, rec in enumerate(fp):
        origid = rec.id
        description = rec.description.replace(origid, "").strip()
        if sep:
            rec.id = rec.description.split(sep)[idx].strip()
        if gb:
            # gi|262233616|gb|GU123895.1| Coffea arabica clone BAC
            atoms = rec.id.split("|")
            if len(atoms) >= 3:
                rec.id = atoms[3]
            elif len(atoms) == 2:
                rec.id = atoms[1]
        if pairs:
            id = "/1" if (i % 2 == 0) else "/2"
            rec.id += id
        if noversion:
            rec.id = rec.id.rsplit(".", 1)[0]
        if sequential:
            rec.id = "{0:0{1}d}".format(sequentialoffset, opts.pad0)
            if sequential == "prefix":
                rec.id = "{0}-{1}".format(rec.id, origid)
            elif sequential == "suffix":
                rec.id = "{0}-{1}".format(origid, rec.id)
            sequentialoffset += 1
        if opts.template:
            template, dir, lib = [x.split("=")[-1] for x in
                    rec.description.split()[1:4]]
            rec.id = "{0}-{1}/{2}".format(lib, template, dir)
        if mapfile:
            if origid in mapping:
                rec.id = mapping[origid]
            else:
                logging.error("{0} not found in `{1}`. ID unchanged.".\
                        format(origid, mapfile))
        if prefix:
            rec.id = prefix + rec.id
        if suffix:
            rec.id += suffix
        if annotfile:
            rec.description = annotation.get(origid, "") if not mapfile \
                    else annotation.get(rec.id, "")
        else:
            rec.description = description if desc else ""
        if idsfile:
            print("\t".join((origid, rec.id)), file=idsfile)
        if upper:
            rec.seq = rec.seq.upper()

        SeqIO.write(rec, fw, "fasta")

    if idsfile:
        logging.debug("Conversion table written to `{0}`.".\
                      format(idsfile.name))
        idsfile.close()
8667
def set_format(self, format):
        
        if self.options.format:
            self.format = self.options.format
        else:
            self.format = \
                self.config["default_format_" + format]
458920
def _insert(wrap: str, tag: Optional[str]) -> str:
        
        if tag is None:
            raise ValueError('tag cannot be None')
        formatter = string.Formatter()
        mapping = FormatDict(component=tag)
        return formatter.vformat(wrap, (), mapping)
323428
public Options putLiteral(String key, String value)
	{
		putOption(key, new LiteralOption(value));
		return this;
	}
325989
def add(self, tagname, tagvalue):
        
        dic = getattr(self, tagname + '_idx')
        try:
            return dic[tagvalue]
        except KeyError:
            dic[tagvalue] = idx = len(dic)
            getattr(self, tagname).append(tagvalue)
            if idx > TWO16:
                raise InvalidFile('contains more then %d tags' % TWO16)
            return idx
1282341
def add_tags(self, dic, prefix):
        
        # fill missing tagvalues with "?", raise an error for unknown tagnames
        idxs = []
        for tagname in self.tagnames:
            if tagname in ('exposure', 'country'):
                idxs.append(self.add(tagname, prefix))
                continue
            try:
                tagvalue = dic.pop(tagname)
            except KeyError:
                tagvalue = '?'
            else:
                if tagvalue in '?*':
                    raise ValueError(
                        'Invalid tagvalue="%s"' % tagvalue)
            idxs.append(self.add(tagname, tagvalue))
        if dic:
            raise ValueError(
                'Unknown tagname %s or <tagNames> not '
                'specified in the exposure' % ', '.join(dic))
        return idxs
282949
def format_html(format_string, *args, **kwargs):
    
    args_safe = map(conditional_escape, args)
    kwargs_safe = dict([(k, conditional_escape(v)) for (k, v) in
                        six.iteritems(kwargs)])
    return mark_safe(format_string.format(*args_safe, **kwargs_safe))
732156
def add_options(cls, parser):
        
        parser.add_option('--show-pydocstyle', action='store_true', help='show explanation of each PEP 257 error')
        parser.config_options.append('show-pydocstyle')
104408
def addFormat(name, fn, opts):
    '''
    
    '''
    fmtyielders[name] = fn
    fmtopts[name] = opts
199137
def add(self, key, value):
        # type: (Hashable, Any) -> None
        
        dict.setdefault(self, key, []).append(value)
223156
def _set_key(self, key, value):
        

        if is_config_section(value):
            self.add_section(key, value)
            return

        if key not in self._tree or self.settings.key_setter is None:
            if is_config_item(value):
                self.add_item(key, value)
                return

            raise TypeError(
                'Section sections/items can only be replaced with sections/items, '
                'got {type}. To set value use ..[{name}].value = <new_value>'.format(
                    type=type(value),
                    name=key,
                )
            )

        if self.settings.key_setter is None:
            self._default_key_setter(key, value)
        else:
            self.settings.key_setter(subject=self._tree[key], value=value, default_key_setter=self._default_key_setter)
659342
def _register_formats(cls):
        """"""
        for fmt in cls.OUTPUT_FORMATS:
            clean_fmt = fmt.replace('+', '_')
            setattr(cls, clean_fmt, property(
                (lambda x, fmt=fmt: cls._output(x, fmt)), # fget
                (lambda x, y, fmt=fmt: cls._input(x, y, fmt))))
486899
def formatter(self, key, value):
        
        template = "PUTVAL {host}/fedmsg/fedmsg_wallboard-{key} " +\
            "interval={interval} {timestamp}:{value}"
        timestamp = int(time.time())
        interval = self.hub.config['collectd_interval']
        return template.format(
            host=self.host,
            timestamp=timestamp,
            value=value,
            interval=interval,
            key=key,
        )
446267
def set_tag(self, key, value):
        
        with self.update_lock:
            if key == ext_tags.SAMPLING_PRIORITY and not self._set_sampling_priority(value):
                return self
            if self.is_sampled():
                tag = thrift.make_tag(
                    key=key,
                    value=value,
                    max_length=self.tracer.max_tag_value_length, )
                self.tags.append(tag)
        return self
779753
function selected2format()
			{
				formatFieldSwitch(true);
				
				formatbar.find("a").click(function()
				{
					$("*",this).click(function(e)
					{
						e.preventDefault();
						return false;
					});
					
					formatLabelView($(this).text());
					
					var formatValue = $(this).attr(vars.css + "-formatval"); // the type of format value
					
					// convert to selected format
					selectionSet("formatBlock",'<'+formatValue+'>');
					
					formatFieldSwitch(false);
				});
			}
597737
def add(self, key, value):
        
        if isinstance(value, list):
            # TODO: support env vars in list w/masked values
            for val in value:
                self._add_arg_python(key, val)
        elif isinstance(value, dict):
            err = 'Dictionary types are not currently supported for field.'
            print('{}{}{}'.format(c.Style.BRIGHT, c.Fore.RED, err))
        else:
            mask = False
            env_var = re.compile(r'^\$env\.(.*)$')
            envs_var = re.compile(r'^\$envs\.(.*)$')

            if env_var.match(str(value)):
                # read value from environment variable
                env_key = env_var.match(str(value)).groups()[0]
                value = os.environ.get(env_key, value)
            elif envs_var.match(str(value)):
                # read secure value from environment variable
                env_key = envs_var.match(str(value)).groups()[0]
                value = os.environ.get(env_key, value)
                mask = True
            self._add_arg(key, value, mask)