Apply format selection.
480679
def do_format(self, format):
        """"""
        infile = self.tmpfile
        outfile = self.basename + '.out'
        outfile_jp2 = self.basename + '.jp2'
        # Now convert finished pnm file to output format
        # simeon@ice ~>cat m3.pnm | pnmtojpeg  > m4.jpg
        # simeon@ice ~>cat m3.pnm | pnmtotiff > m4.jpg
        # pnmtotiff: computing colormap...
        # pnmtotiff: Too many colors - proceeding to write a 24-bit RGB file.
        # pnmtotiff: If you want an 8-bit palette file, try doing a 'ppmquant 256'.
        # simeon@ice ~>cat m3.pnm | pnmtopng  > m4.png
        fmt = ('png' if (format is None) else format)
        if (fmt == 'png'):
            # print "format: png"
            if (self.shell_call(self.pnmtopng + ' ' + infile + ' > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmtopng.")
            mime_type = "image/png"
        elif (fmt == 'jpg'):
            # print "format: jpg"
            if (self.shell_call(self.pnmtojpeg + ' ' + infile + ' > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmtojpeg.")
            mime_type = "image/jpeg"
        elif (fmt == 'tiff' or fmt == 'jp2'):
            # print "format: tiff/jp2"
            if (self.shell_call(self.pnmtotiff + ' ' + infile + ' > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmtotiff.")
            mime_type = "image/tiff"
            if (fmt == 'jp2'):
                # use djatoka after tiff
                if (self.shell_call(DJATOKA_COMP + ' -i ' + outfile + ' -o ' + outfile_jp2)):
                    raise IIIFError(
                        text="Oops... got nonzero output from DJATOKA_COMP.")
                mime_type = "image/jp2"
                outfile = tmpfile_jp2
        else:
            raise IIIFError(code=415, parameter='format',
                            text="Unsupported output file format (%s), only png,jpg,tiff are supported." % (fmt))
        self.outfile = outfile
        self.output_format = fmt
        self.mime_type = mime_type
845595
function formatIf (bool, format, arr, ref) {
  if (bool) {
    arr.unshift(format)
    return util.format.apply({}, arr)
  }
  else
    return ref
}
226592
def set_format_options(fmt, format_options):
    """"""
    if not format_options:
        return

    for opt in format_options:
        try:
            key, value = opt.split('=')
        except ValueError:
            raise ValueError("Format options are expected to be of the form key=value, not '{}'".format(opt))

        if key not in _VALID_FORMAT_OPTIONS:
            raise ValueError("'{}' is not a valid format option. Expected one of '{}'"
                             .format(key, "', '".join(_VALID_FORMAT_OPTIONS)))

        if key in _BINARY_FORMAT_OPTIONS:
            value = str2bool(value)

        fmt[key] = value
348579
def is_format_selected(image_format, formats, progs):
    """"""
    intersection = formats & Settings.formats
    mode = _is_program_selected(progs)
    result = (image_format in intersection) and mode
    return result
4648
def formatted(self):
        """"""
        return ' '.join(self.compact[i:i + 4] for i in range(0, len(self.compact), 4))
950303
def format_doc(hit, schema, dates):
    """"""
    doc = hit.get('_source', {})
    doc.setdefault(config.ID_FIELD, hit.get('_id'))
    doc.setdefault('_type', hit.get('_type'))
    if hit.get('highlight'):
        doc['es_highlight'] = hit.get('highlight')

    if hit.get('inner_hits'):
        doc['_inner_hits'] = {}
        for key, value in hit.get('inner_hits').items():
            doc['_inner_hits'][key] = []
            for item in value.get('hits', {}).get('hits', []):
                doc['_inner_hits'][key].append(item.get('_source', {}))

    for key in dates:
        if key in doc:
            doc[key] = parse_date(doc[key])

    return doc
198307
def apply_markup(value, arg=None):
    
    if arg is not None:
        return formatter(value, filter_name=arg)
    return formatter(value)
489154
function selectFormat(format) {
  let method = "toTable";
  let extension = `.${format}`;

  switch (format) {
    case "json":
      method = "toJSON";
      break;
    case "csv":
      method = "toCSV";
      break;
    case "html":
      method = "toHTML";
      break;
    case "md":
      method = "toMarkdown";
      break;
    default:
      break;
  }

  return {
    extension: extension,
    method: method
  }
}
343605
function setFormat(format) {
            if (format === null || format === undefined) {
                throw new Error("Format is not defined " + this.clazz.$name);
            }

            if (this.format !== format) {
                this.format = format;
                this.$getSuper("setValue").call(this, this.$format(this.date));
            }

            return this;
        }
424777
def format_theme(selection):
    """"""
    global themefile

    text = open(THEMEDIR + '/' + selection).read()
    if '!dotcolors' in text[:10]:
        themefile = text
        return

    lines = ['!dotcolors auto formatted\n']
    for line in text.split('\n'):
        lline = line.lower()
        background = 'background' in lline
        foreground = 'foreground' in lline
        color = 'color' in lline

        if background:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*background:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if foreground:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*foreground:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if color:
            if lline[0] != '!':
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))
    
    themefile = '\n'.join(lines) + '\n'
    fd, tmpfile = tempfile.mkstemp()
    if exists( THEMEDIR + '/' + selection ):
        old = open( THEMEDIR + '/' + selection )
        new = os.fdopen(fd, 'w')
        os.write(fd, themefile)
        old.close()
        new.close()
        move( tmpfile, THEMEDIR + '/' + selection )
449097
def format_line(data, linestyle):
    """"""
    return linestyle.begin + linestyle.sep.join(data) + linestyle.end
3805
def _attempt_to_choose_formatting_pattern(self):
        """"""
        # We start to attempt to format only when at least MIN_LEADING_DIGITS_LENGTH digits of national
        # number (excluding national prefix) have been entered.
        if len(self._national_number) >= _MIN_LEADING_DIGITS_LENGTH:
            self._get_available_formats(self._national_number)
            # See if the accrued digits can be formatted properly already.
            formatted_number = self._attempt_to_format_accrued_digits()
            if len(formatted_number) > 0:
                return formatted_number
            if self._maybe_create_new_template():
                return self._input_accrued_national_number()
            else:
                return self._accrued_input
        else:
            return self._append_national_number(self._national_number)
644175
def reapply_styles
      selected.each do |selected_view|
        selected_view.rmq_data.styles.each do |style_name|
          apply_style_to_view selected_view, style_name
        end
      end
      self
    end
249713
function addFormat(name, format) {
  if (typeof format == 'string') format = new RegExp(format);
  this._formats[name] = format;
  return this;
}
671512
public static function applyformatToText() {
    $args = func_get_args();
    $count = func_num_args();

    $text = $args[$count - 1];
    if ($count == 1) { return $text; }

    $mode_texts = array_slice($args, 0, $count - 1);

    return self::buildEscapeCodes($mode_texts).$text.self::buildEscapeCodes('plain');
  }
698588
def paste_to_selection(self, selection, data, freq=None):
        """"""

        (bb_top, bb_left), (bb_bottom, bb_right) = \
            selection.get_grid_bbox(self.grid.code_array.shape)
        adjusted_data = self.selection_paste_data_gen(selection, data)
        self.paste_to_current_cell((bb_top, bb_left), adjusted_data, freq=freq)
1255041
def format_usage(self, ctx, formatter):
        """"""
        pieces = self.collect_usage_pieces(ctx)
        formatter.write_usage(ctx.command_path, ' '.join(pieces))