Writes the dbf records.
768910
def __dbfRecord(self, record):
        """"""
        f = self.__getFileObj(self.dbf)
        if self.recNum == 0:
            # first records, so all fields should be set
            # allowing us to write the dbf header
            # cannot change the fields after this point
            self.__dbfHeader()
        # begin
        self.recNum += 1
        if not self.fields[0][0].startswith("Deletion"):
            f.write(b' ') # deletion flag
        for (fieldName, fieldType, size, deci), value in zip(self.fields, record):
            fieldType = fieldType.upper()
            size = int(size)
            if fieldType in ("N","F"):
                # numeric or float: number stored as a string, right justified, and padded with blanks to the width of the field.
                if value in MISSING:
                    value = b"*"*size # QGIS NULL
                elif not deci:
                    # force to int
                    try:
                        # first try to force directly to int.
                        # forcing a large int to float and back to int
                        # will lose information and result in wrong nr.
                        value = int(value) 
                    except ValueError:
                        # forcing directly to int failed, so was probably a float.
                        value = int(float(value))
                    value = format(value, "d")[:size].rjust(size) # caps the size if exceeds the field size
                else:
                    value = float(value)
                    value = format(value, ".%sf"%deci)[:size].rjust(size) # caps the size if exceeds the field size
            elif fieldType == "D":
                # date: 8 bytes - date stored as a string in the format YYYYMMDD.
                if isinstance(value, date):
                    value = '{:04d}{:02d}{:02d}'.format(value.year, value.month, value.day)
                elif isinstance(value, list) and len(value) == 3:
                    value = '{:04d}{:02d}{:02d}'.format(*value)
                elif value in MISSING:
                    value = b'0' * 8 # QGIS NULL for date type
                elif is_string(value) and len(value) == 8:
                    pass # value is already a date string
                else:
                    raise ShapefileException("Date values must be either a datetime.date object, a list, a YYYYMMDD string, or a missing value.")
            elif fieldType == 'L':
                # logical: 1 byte - initialized to 0x20 (space) otherwise T or F.
                if value in MISSING:
                    value = b' ' # missing is set to space
                elif value in [True,1]:
                    value = b'T'
                elif value in [False,0]:
                    value = b'F'
                else:
                    value = b' ' # unknown is set to space
            else:
                # anything else is forced to string, truncated to the length of the field
                value = b(value, self.encoding, self.encodingErrors)[:size].ljust(size)
            if not isinstance(value, bytes):
                # just in case some of the numeric format() and date strftime() results are still in unicode (Python 3 only)
                value = b(value, 'ascii', self.encodingErrors) # should be default ascii encoding
            if len(value) != size:
                raise ShapefileException(
                    "Shapefile Writer unable to pack incorrect sized value"
                    " (size %d) into field '%s' (size %d)." % (len(value), fieldName, size))
            f.write(value)
307447
private function _saveRecords()
    {
        $offset = 50;
        if (is_array($this->records) && (count($this->records) > 0)) {
            foreach ($this->records as $index => $record) {
                //Save the record to the .shp file
                $record->saveToFile($this->SHPFile, $this->DBFFile, $index + 1);

                //Save the record to the .shx file
                fwrite($this->SHXFile, pack('N', $offset));
                fwrite($this->SHXFile, pack('N', $record->getContentLength()));
                $offset += (4 + $record->getContentLength());
            }
        }
    }
1174074
def save_records(self, records):
        '''
        
        '''
        for record in records:
            if not isinstance(record, Record):
                record = Record(*record)
            self.save_record(*record)
688319
def write(self):
        
        # write data
        self.project_manager.writeInput(session=self.db_session,
                                        directory=self.project_directory,
                                        name=self.project_manager.name)
799411
private function write()
	{
		$content = '';

		foreach ($this->getFiles() as $file)
		{
			$content .= '$this->call(\'' . str_replace('.php', '', $file) . '\');';	
		}
		
		$databaseSeeder = str_replace('{calls}', $content, $this->getPattern());

		$this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $databaseSeeder);
	}
883355
public void write(Object[] record) throws IOException, DbaseFileException {

		if (record.length != header.getNumFields()) {
			throw new DbaseFileException("Wrong number of fields "
					+ record.length + " expected " + header.getNumFields());
		}

		buffer.position(0);

		// put the 'not-deleted' marker
		buffer.put((byte) ' ');

		for (int i = 0; i < header.getNumFields(); i++) {
			String fieldString = fieldString(record[i], i);
			if (header.getFieldLength(i) != fieldString
					.getBytes(charset.name()).length) {
				buffer.put(new byte[header.getFieldLength(i)]);
			} else {
				buffer.put(fieldString.getBytes(charset.name()));
			}

		}

		write();
	}
1298333
private function write()
    {
        $cache = serialize($this->records);
        flock($this->file, LOCK_EX);
        rewind($this->file);
        ftruncate($this->file, 0);
        $bytes = fwrite($this->file, $cache);
        flock($this->file, LOCK_UN);

        return $bytes === strlen($cache);
    }
637784
def records(self):
        """"""
        if not self.numRecords:
            self.__dbfHeader()
        records = []
        f = self.__getFileObj(self.dbf)
        f.seek(self.__dbfHeaderLength())
        for i in range(self.numRecords):
            r = self.__record()
            if r:
                records.append(r)
        return records
12957
def db_for_write(self, model, **hints):
        
        if 'instance' in hints:
            db = hints['instance']._state.db
            if db:
                return db
        if getattr(model, '_salesforce_object', False):
            return self.sf_alias
985296
def write_tf_examples(filename, tf_examples, serialize=True):
    
    with tf.python_io.TFRecordWriter(
            filename, options=TF_RECORD_CONFIG) as writer:
        for ex in tf_examples:
            if serialize:
                writer.write(ex.SerializeToString())
            else:
                writer.write(ex)
817604
@SuppressWarnings("checkstyle:magicnumber")
	private void writeDBFDate(Date date) throws IOException {
		final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
		writeDBFString(format.format(date), 8, (byte) ' ');
	}
661680
def record(self, i=0):
        """"""
        f = self.__getFileObj(self.dbf)
        if not self.numRecords:
            self.__dbfHeader()
        i = self.__restrictIndex(i)
        recSize = self.__recordFmt()[1]
        f.seek(0)
        f.seek(self.__dbfHeaderLength() + (i * recSize))
        return self.__record()
1297348
function writeXf()
	{
		// Set the type of the XF record and some of the attributes.
		if ($this->_isStyleXf) {
			$style = 0xFFF5;
		} else {
			$style   = self::_mapLocked($this->_style->getProtection()->getLocked());
			$style  |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
		}

		// Flags to indicate if attributes have been set.
		$atr_num     = ($this->_numberFormatIndex != 0)?1:0;
		$atr_fnt     = ($this->_fontIndex != 0)?1:0;
		$atr_alc     = ((int) $this->_style->getAlignment()->getWrapText())?1:0;
		$atr_bdr     = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())   ||
						self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())      ||
						self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle())     ||
						self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
		$atr_pat     = (($this->_fg_color != 0x40) ||
						($this->_bg_color != 0x41) ||
						self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
		$atr_prot    = self::_mapLocked($this->_style->getProtection()->getLocked())
						| self::_mapHidden($this->_style->getProtection()->getHidden());

		// Zero the default border colour if the border has not been set.
		if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
			$this->_bottom_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())  == 0) {
			$this->_top_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
			$this->_right_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
			$this->_left_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
			$this->_diag_color = 0;
		}

		$record         = 0x00E0;              // Record identifier
		$length         = 0x0014;              // Number of bytes to follow

		$ifnt           = $this->_fontIndex;   // Index to FONT record
		$ifmt           = $this->_numberFormatIndex;  // Index to FORMAT record

		$align          = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal());       // Alignment
		$align         |= (int) $this->_style->getAlignment()->getWrapText()     << 3;
		$align         |= self::_mapVAlign($this->_style->getAlignment()->getVertical())  << 4;
		$align         |= $this->_text_justlast << 7;

		$used_attrib    = $atr_num              << 2;
		$used_attrib   |= $atr_fnt              << 3;
		$used_attrib   |= $atr_alc              << 4;
		$used_attrib   |= $atr_bdr              << 5;
		$used_attrib   |= $atr_pat              << 6;
		$used_attrib   |= $atr_prot             << 7;

		$icv            = $this->_fg_color;      // fg and bg pattern colors
		$icv           |= $this->_bg_color      << 7;

		$border1        = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());          // Border line style and color
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())         << 4;
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())           << 8;
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())        << 12;
		$border1       |= $this->_left_color    << 16;
		$border1       |= $this->_right_color   << 23;

		$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
		$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
							|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
		$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
							|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
		$border1       |= $diag_tl_to_rb        << 30;
		$border1       |= $diag_tr_to_lb        << 31;

		$border2        = $this->_top_color;    // Border color
		$border2       |= $this->_bottom_color   << 7;
		$border2       |= $this->_diag_color     << 14;
		$border2       |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle())           << 21;
		$border2       |= self::_mapFillType($this->_style->getFill()->getFillType())        << 26;

		$header      = pack("vv",       $record, $length);

		//BIFF8 options: identation, shrinkToFit and  text direction
		$biff8_options  = $this->_style->getAlignment()->getIndent();
		$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;

		$data  = pack("vvvC", $ifnt, $ifmt, $style, $align);
		$data .= pack("CCC"
			, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
			, $biff8_options
			, $used_attrib
			);
		$data .= pack("VVv", $border1, $border2, $icv);

		return($header . $data);
	}
1230869
@Override
  public void write(JdbcEntryData record) throws IOException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Writing " + record);
    }
    try {
      this.commands.insert(this.databaseName, this.tableName, record);
      this.recordWrittenCount++;
    } catch (Exception e) {
      this.failed = true;
      throw new RuntimeException(e);
    }
  }
1206942
private function _writeDimensions()
	{
		$record = 0x0200; // Record identifier

		$length = 0x000E;
		$data = pack('VVvvv'
				, $this->_firstRowIndex
				, $this->_lastRowIndex + 1
				, $this->_firstColumnIndex
				, $this->_lastColumnIndex + 1
				, 0x0000 // reserved
			);

		$header = pack("vv", $record, $length);
		$this->_append($header.$data);
	}
697334
def WriteBlobs(self, blob_id_data_map):
    """"""

    urns = {self._BlobUrn(blob_id): blob_id for blob_id in blob_id_data_map}

    mutation_pool = data_store.DB.GetMutationPool()

    existing = aff4.FACTORY.MultiOpen(
        urns, aff4_type=aff4.AFF4MemoryStreamBase, mode="r")

    for blob_urn, blob_id in iteritems(urns):
      if blob_urn in existing:
        logging.debug("Blob %s already stored.", blob_id)
        continue

      with aff4.FACTORY.Create(
          blob_urn,
          aff4.AFF4UnversionedMemoryStream,
          mode="w",
          mutation_pool=mutation_pool) as fd:
        content = blob_id_data_map[blob_id]
        fd.Write(content)

      logging.debug("Got blob %s (length %s)", blob_id.AsHexString(),
                    len(content))

    mutation_pool.Flush()
704862
def write_record(self, mem_addr: int, mode: str, group: int, target,
                     data1=0x00, data2=0x00, data3=0x00):
        """"""
        if not (self._have_first_record() and self._have_last_record()):
            _LOGGER.error('Must load the Insteon All-Link Database before '
                          'writing to it')
        else:
            self._prior_status = self._status
            self._status = ALDBStatus.LOADING
            mem_hi = mem_addr >> 8
            mem_lo = mem_addr & 0xff
            controller = mode == 'c'
            control_flag = ControlFlags(True, controller, True, False, False)
            addr = Address(target)
            addr_lo = addr.bytes[0]
            addr_mid = addr.bytes[1]
            addr_hi = addr.bytes[2]
            userdata = Userdata({'d1': 0,
                                 'd2': 0x02,
                                 'd3': mem_hi,
                                 'd4': mem_lo,
                                 'd5': 0x08,
                                 'd6': control_flag.byte,
                                 'd7': group,
                                 'd8': addr_lo,
                                 'd9': addr_mid,
                                 'd10': addr_hi,
                                 'd11': data1,
                                 'd12': data2,
                                 'd13': data3})
            msg = ExtendedSend(self._address,
                               COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00,
                               userdata=userdata)
            msg.set_checksum()
            _LOGGER.debug('writing message %s', msg)
            self._send_method(msg, self._handle_write_aldb_ack, True)
            self._load_action = LoadAction(mem_addr, 1, 0)