Write BIFF record Window2.
551863
def store_window2   #:nodoc:
    record         = 0x023E     # Record identifier
    length         = 0x0012     # Number of bytes to follow

    grbit          = 0x00B6     # Option flags
    rwTop          = @first_row   # Top visible row
    colLeft        = @first_col   # Leftmost visible column
    rgbHdr         = 0x00000040            # Row/col heading, grid color

    wScaleSLV      = 0x0000                # Zoom in page break preview
    wScaleNormal   = 0x0000                # Zoom in normal view
    reserved       = 0x00000000


    # The options flags that comprise $grbit
    fDspFmla       = @display_formulas # 0 - bit
    fDspGrid       = @screen_gridlines # 1
    fDspRwCol      = @display_headers  # 2
    fFrozen        = frozen? ? 1 : 0   # 3
    fDspZeros      = display_zeros? ? 1 : 0   # 4
    fDefaultHdr    = 1                 # 5
    fArabic        = @display_arabic || 0  # 6
    fDspGuts       = @outline.visible? ? 1 : 0       # 7
    fFrozenNoSplit = @frozen_no_split  # 0 - bit
    fSelected      = selected? ? 1 : 0 # 1
    fPaged         = active? ?   1 : 0 # 2
    fBreakPreview  = 0                # 3

    grbit             = fDspFmla
    grbit            |= fDspGrid       << 1
    grbit            |= fDspRwCol      << 2
    grbit            |= fFrozen        << 3
    grbit            |= fDspZeros      << 4
    grbit            |= fDefaultHdr    << 5
    grbit            |= fArabic        << 6
    grbit            |= fDspGuts       << 7
    grbit            |= fFrozenNoSplit << 8
    grbit            |= fSelected      << 9
    grbit            |= fPaged         << 10
    grbit            |= fBreakPreview  << 11

    header = [record, length].pack("vv")
    data    =[grbit, rwTop, colLeft, rgbHdr, wScaleSLV, wScaleNormal, reserved].pack("vvvVvvV")

    append(header, data)
  end
393472
def write_Bar(file, bar, bpm=120, repeat=0, verbose=False):
    
    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.play_Bar(bar)
        repeat -= 1
    return m.write_file(file, verbose)
463257
def write_shiftfile(image_list, filename, outwcs='tweak_wcs.fits'):
    
    rows = ''
    nrows = 0
    for img in image_list:
        row = img.get_shiftfile_row()
        if row is not None:
            rows += row
            nrows += 1
    if nrows == 0:  # If there are no fits to report, do not write out a file
        return

    # write out reference WCS now
    if os.path.exists(outwcs):
        os.remove(outwcs)
    p = fits.HDUList()
    p.append(fits.PrimaryHDU())
    p.append(createWcsHDU(image_list[0].refWCS))
    p.writeto(outwcs)

    # Write out shiftfile to go with reference WCS
    with open(filename, 'w') as f:
        f.write('# frame: output\n')
        f.write('# refimage: %s[wcs]\n' % outwcs)
        f.write('# form: delta\n')
        f.write('# units: pixels\n')
        f.write(rows)
    print('Writing out shiftfile :', filename)
7779
function write_biff_rec(ba, t, payload, length) {
	var len = (length || (payload||[]).length);
	var o = ba.next(4 + len);
	o.write_shift(2, t);
	o.write_shift(2, len);
	if(len > 0 && is_buf(payload)) ba.push(payload);
}
1241860
def writeout(ds, outfn):
    
    print("Writing out %s" % outfn) 
    #Use outfn extension to get driver
    #This may have issues if outfn already exists and the mem ds has different dimensions/res
    out_ds = iolib.gtif_drv.CreateCopy(outfn, ds, 0, options=iolib.gdal_opt)
    out_ds = None
882641
function write_BIFF2LABEL(r/*:number*/, c/*:number*/, val) {
	var out = new_buf(8 + 2*val.length);
	write_BIFF2Cell(out, r, c);
	out.write_shift(1, val.length);
	out.write_shift(val.length, val, 'sbcs');
	return out.l < out.length ? out.slice(0, out.l) : out;
}
744002
def write_freqt(docgraph, output_filepath, include_pos=False):
    """"""
    path_to_file = os.path.dirname(output_filepath)
    if not os.path.isdir(path_to_file):
        create_dir(path_to_file)
    with codecs.open(output_filepath, 'w', 'utf-8') as output_file:
        for sentence in docgraph.sentences:
            output_file.write(docgraph2freqt(docgraph, sentence,
                              include_pos=include_pos)+'\n')
1208138
def write_record(self, record):
        ''''''
        # FIXME: probably not a good idea to modifiy arguments passed to us
        # TODO: add extra gzip headers that wget uses
        record.fields['WARC-Warcinfo-ID'] = self._warcinfo_record.fields[
            WARCRecord.WARC_RECORD_ID]

        _logger.debug('Writing WARC record {0}.',
                      record.fields['WARC-Type'])

        if self._params.compress:
            open_func = gzip.GzipFile
        else:
            open_func = open

        # Use getsize to get actual file size. Avoid tell() because it may
        # not be the raw file position.
        if os.path.exists(self._warc_filename):
            before_offset = os.path.getsize(self._warc_filename)
        else:
            before_offset = 0

        journal_filename = self._warc_filename + '-wpullinc'

        with open(journal_filename, 'w') as file:
            file.write('wpull-journal-version:1\n')
            file.write('offset:{}\n'.format(before_offset))

        try:
            with open_func(self._warc_filename, mode='ab') as out_file:
                for data in record:
                    out_file.write(data)
        except (OSError, IOError) as error:
            _logger.info(
                _('Rolling back file {filename} to length {length}.'),
                filename=self._warc_filename, length=before_offset
            )
            with open(self._warc_filename, mode='wb') as out_file:
                out_file.truncate(before_offset)

            raise error
        finally:
            os.remove(journal_filename)

        after_offset = os.path.getsize(self._warc_filename)

        if self._cdx_filename:
            raw_file_offset = before_offset
            raw_file_record_size = after_offset - before_offset

            self._write_cdx_field(
                record, raw_file_record_size, raw_file_offset
            )
1280758
def __interact_writen(self, fd, data):
        '''
        '''

        while data != b'' and self.isalive():
            n = os.write(fd, data)
            data = data[n:]
377909
def write_frame(self, buf):
        '''
        
        '''
        writer = Writer(buf)
        writer.write_octet(self.type())
        writer.write_short(self.channel_id)

        # Track the position where we're going to write the total length
        # of the frame arguments.
        stream_args_len_pos = len(buf)
        writer.write_long(0)

        stream_method_pos = len(buf)

        writer.write_short(self._class_id)
        writer.write_short(self._weight)
        writer.write_longlong(self._size)

        # Like frame parsing, branch to faster code for default properties
        if self.DEFAULT_PROPERTIES:
            # Track the position where we're going to write the flags.
            flags_pos = len(buf)
            writer.write_short(0)
            flag_bits = 0
            for key, proptype, rfunc, wfunc, mask in self.PROPERTIES:
                val = self._properties.get(key, None)
                if val is not None:
                    flag_bits |= mask
                    wfunc(writer, val)
            writer.write_short_at(flag_bits, flags_pos)
        else:
            shift = 15
            flag_bits = 0
            flags = []
            stack = deque()
            for key, proptype, rfunc, wfunc, mask in self.PROPERTIES:
                val = self._properties.get(key, None)
                if val is not None:
                    if shift == 0:
                        flags.append(flag_bits)
                        flag_bits = 0
                        shift = 15

                    flag_bits |= (1 << shift)
                    stack.append((wfunc, val))

                shift -= 1

            flags.append(flag_bits)
            for flag_bits in flags:
                writer.write_short(flag_bits)
            for method, val in stack:
                method(writer, val)

        # Write the total length back at the beginning of the frame
        stream_len = len(buf) - stream_method_pos
        writer.write_long_at(stream_len, stream_args_len_pos)

        writer.write_octet(0xce)
1013501
def _write(self, session, openFile, replaceParamFile):
        
        ## TODO: Ensure Other HMET Formats are supported
        hmetRecords = self.hmetRecords

        for record in hmetRecords:
            openFile.write('%s\t%s\t%s\t%s\t%.3f\t%s\t%s\t%s\t%s\t%.2f\t%.2f\n' % (
                record.hmetDateTime.year,
                record.hmetDateTime.month,
                record.hmetDateTime.day,
                record.hmetDateTime.hour,
                record.barometricPress,
                record.relHumidity,
                record.totalSkyCover,
                record.windSpeed,
                record.dryBulbTemp,
                record.directRad,
                record.globalRad))
472026
def write_conf(self):
        
        f = open(self.output_filename, 'w')
        print(self.t.render(prefixes=self.prefixes), file=f)
        f.close()
148985
function write_biff8_buf(wb, opts) {
	var o = opts || {};
	var bufs = [];

	if(wb && !wb.SSF) {
		wb.SSF = SSF.get_table();
	}
	if(wb && wb.SSF) {
		make_ssf(SSF); SSF.load_table(wb.SSF);
		// $FlowIgnore
		o.revssf = evert_num(wb.SSF); o.revssf[wb.SSF[65535]] = 0;
		o.ssf = wb.SSF;
	}
	o.cellXfs = [];
	o.Strings = []; o.Strings.Count = 0; o.Strings.Unique = 0;
	get_cell_style(o.cellXfs, {}, {revssf:{"General":0}});

	for(var i = 0; i < wb.SheetNames.length; ++i) bufs[bufs.length] = write_ws_biff8(i, o, wb);
	bufs.unshift(write_biff8_global(wb, bufs, o));
	return __toBuffer([bufs]);
}
755859
private function _readWindow2()
	{
		$length = self::_GetInt2d($this->_data, $this->_pos + 2);
		$recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length);

		// move stream pointer to next record
		$this->_pos += 4 + $length;

		// offset: 0; size: 2; option flags
		$options = self::_GetInt2d($recordData, 0);

		// offset: 2; size: 2; index to first visible row
		$firstVisibleRow = self::_GetInt2d($recordData, 2);

		// offset: 4; size: 2; index to first visible colum
		$firstVisibleColumn = self::_GetInt2d($recordData, 4);
		if ($this->_version === self::XLS_BIFF8) {
			// offset:  8; size: 2; not used
			// offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%)
			// offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%)
			// offset: 14; size: 4; not used
			$zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10);
			if ($zoomscaleInPageBreakPreview === 0) $zoomscaleInPageBreakPreview = 60;
			$zoomscaleInNormalView = self::_GetInt2d($recordData, 12);
			if ($zoomscaleInNormalView === 0) $zoomscaleInNormalView = 100;
		}

		// bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines
		$showGridlines = (bool) ((0x0002 & $options) >> 1);
		$this->_phpSheet->setShowGridlines($showGridlines);

		// bit: 2; mask: 0x0004; 0 = do not show headers, 1 = show headers
		$showRowColHeaders = (bool) ((0x0004 & $options) >> 2);
		$this->_phpSheet->setShowRowColHeaders($showRowColHeaders);

		// bit: 3; mask: 0x0008; 0 = panes are not frozen, 1 = panes are frozen
		$this->_frozen = (bool) ((0x0008 & $options) >> 3);

		// bit: 6; mask: 0x0040; 0 = columns from left to right, 1 = columns from right to left
		$this->_phpSheet->setRightToLeft((bool)((0x0040 & $options) >> 6));

		// bit: 10; mask: 0x0400; 0 = sheet not active, 1 = sheet active
		$isActive = (bool) ((0x0400 & $options) >> 10);
		if ($isActive) {
			$this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet));
		}

		// bit: 11; mask: 0x0800; 0 = normal view, 1 = page break view
		$isPageBreakPreview = (bool) ((0x0800 & $options) >> 11);

		//FIXME: set $firstVisibleRow and $firstVisibleColumn

		if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) {
			//NOTE: this setting is inferior to page layout view(Excel2007-)
			$view = $isPageBreakPreview? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW :
				PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL;
			$this->_phpSheet->getSheetView()->setView($view);
			if ($this->_version === self::XLS_BIFF8) {
				$zoomScale = $isPageBreakPreview? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView;
				$this->_phpSheet->getSheetView()->setZoomScale($zoomScale);
				$this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView);
			}
		}
	}
1105338
def __shxRecord(self, offset, length):
         """"""
         f = self.__getFileObj(self.shx)
         f.write(pack(">i", offset // 2))
         f.write(pack(">i", length))
1072628
def WriteBlobToFile(self, request):
    """"""
    # First chunk truncates the file, later chunks append.
    if request.offset == 0:
      mode = "w+b"
    else:
      mode = "r+b"

    temp_file = tempfiles.CreateGRRTempFile(
        filename=request.write_path, mode=mode)
    with temp_file:
      path = temp_file.name
      temp_file.seek(0, 2)
      if temp_file.tell() != request.offset:
        raise IOError("Chunks out of order Error.")

      # Write the new chunk.
      temp_file.write(request.executable.data)

    return path
1288873
public void writeDirect ( byte[] b, int off, int len, int flags ) throws IOException {
        if ( len <= 0 ) {
            return;
        }

        if ( this.tmp == null ) {
            throw new IOException("Bad file descriptor");
        }

        try ( SmbFileHandleImpl fh = ensureOpen();
              SmbTreeHandleImpl th = fh.getTree() ) {
            if ( log.isDebugEnabled() ) {
                log.debug("write: fid=" + fh + ",off=" + off + ",len=" + len);
            }

            int w;
            do {
                int blockSize = ( this.file.getType() == SmbConstants.TYPE_FILESYSTEM ) ? this.writeSizeFile : this.writeSize;
                w = len > blockSize ? blockSize : len;

                if ( this.smb2 ) {
                    Smb2WriteRequest wr = new Smb2WriteRequest(th.getConfig(), fh.getFileId());
                    wr.setOffset(this.fp);
                    wr.setData(b, off, w);

                    Smb2WriteResponse resp = th.send(wr, RequestParam.NO_RETRY);
                    long cnt = resp.getCount();
                    this.fp += cnt;
                    len -= cnt;
                    off += cnt;
                }
                else if ( this.useNTSmbs ) {
                    this.reqx.setParam(fh.getFid(), this.fp, len - w, b, off, w);
                    if ( ( flags & 1 ) != 0 ) {
                        this.reqx.setParam(fh.getFid(), this.fp, len, b, off, w);
                        this.reqx.setWriteMode(0x8);
                    }
                    else {
                        this.reqx.setWriteMode(0);
                    }

                    th.send(this.reqx, this.rspx, RequestParam.NO_RETRY);
                    long cnt = this.rspx.getCount();
                    this.fp += cnt;
                    len -= cnt;
                    off += cnt;
                }
                else {
                    if ( log.isTraceEnabled() ) {
                        log.trace(String.format("Wrote at %d remain %d off %d len %d", this.fp, len - w, off, w));
                    }
                    this.req.setParam(fh.getFid(), this.fp, len - w, b, off, w);
                    th.send(this.req, this.rsp);
                    long cnt = this.rsp.getCount();
                    this.fp += cnt;
                    len -= cnt;
                    off += cnt;
                    if ( log.isTraceEnabled() ) {
                        log.trace(String.format("Wrote at %d remain %d off %d len %d", this.fp, len - w, off, w));
                    }
                }

            }
            while ( len > 0 );
        }
    }