Build payload of all parts and write them into the payload buffer
194736
def build_payload(self, payload):
        """"""
        remaining_size = self.MAX_SEGMENT_PAYLOAD_SIZE

        for part in self.parts:
            part_payload = part.pack(remaining_size)
            payload.write(part_payload)
            remaining_size -= len(part_payload)
1333321
def _write_parts(phys_writer, parts):
        
        for part in parts:
            phys_writer.write(part.partname, part.blob)
            if len(part._rels):
                phys_writer.write(part.partname.rels_uri, part._rels.xml)
225844
def write_chunks(out, chunks):
    """"""

    out.write(_signature)
    for chunk in chunks:
        write_chunk(out, *chunk)
742070
protected static byte[] toArray(ByteBuffer... payload) {
        if (payload.length == 1) {
            ByteBuffer buf = payload[0];
            if (buf.hasArray() && buf.arrayOffset() == 0 && buf.position() == 0) {
                return buf.array();
            }
        }
        int size = (int) Buffers.remaining(payload);
        byte[] data = new byte[size];
        for (ByteBuffer buf : payload) {
            buf.get(data);
        }
        return data;
    }
1124258
public WsByteBuffer[] buildFrameArrayForWrite() {
        WsByteBuffer[] output;

        int headerSize = SIZE_FRAME_BEFORE_PAYLOAD;
        if (PADDED_FLAG) {
            headerSize = SIZE_FRAME_BEFORE_PAYLOAD + 1;
        }
        WsByteBuffer frameHeaders = getBuffer(headerSize);
        byte[] frame;
        if (frameHeaders.hasArray()) {
            frame = frameHeaders.array();
        } else {
            frame = super.createFrameArray();
        }

        // add the first 9 bytes of the array
        setFrameHeaders(frame, utils.FRAME_TYPE_DATA);

        // set up the frame payload
        int frameIndex = SIZE_FRAME_BEFORE_PAYLOAD;

        // add pad length field
        if (PADDED_FLAG) {
            utils.Move8BitstoByteArray(paddingLength, frame, frameIndex);
            frameIndex++;
        }
        frameHeaders.put(frame, 0, headerSize);
        frameHeaders.flip();

        // create padding and put in return buffer array
        if (PADDED_FLAG) {
            WsByteBuffer padding = getBuffer(paddingLength);
            for (int i = 0; i < paddingLength; i++) {
                padding.put((byte) 0);
            }
            padding.flip();
            output = new WsByteBuffer[3];
            output[0] = frameHeaders;
            output[1] = dataBuffer;
            output[2] = padding;
        }
        // create the output buffer array
        else {
            output = new WsByteBuffer[2];
            output[0] = frameHeaders;
            output[1] = dataBuffer;
        }
        return output;
    }
191155
def write(self, data):
        """"""
        data = data.encode('utf-8')
        data_p = ctypes.create_string_buffer(data)
        num_bytes = PLARGE_INTEGER(LARGE_INTEGER(0))
        bytes_to_write = len(data)
        success = WriteFile(self.conin_pipe, data_p,
                            bytes_to_write, num_bytes, None)
        return success, num_bytes[0]
956373
def prepare_multipart_data(payload)
      boundary = "infosimples" + rand(1_000_000).to_s # a random unique string

      content = []
      payload.each do |param, value|
        content << '--' + boundary
        content << "Content-Disposition: form-data; name=\"#{param}\""
        content << ''
        content << value
      end
      content << '--' + boundary + '--'
      content << ''

      [boundary, content.join("\r\n")]
    end
865937
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect,
            PemEncoded encoded, int count, ByteBuf pem) {

        ByteBuf content = encoded.content();

        if (pem == null) {
            // see the other append() method
            pem = newBuffer(allocator, useDirect, content.readableBytes() * count);
        }

        pem.writeBytes(content.slice());
        return pem;
    }
892303
def dump
      {
          'args'            => self.args,
          'worker'          => self.worker,
          'queue'           => self.queue,

          'status'          => self.status,
          'at'              => self.at,
          'total'           => self.total,
          'message'         => self.message,

          'payload'         => self.payload,
          'last_updated_at' => Time.now.to_i
      }
    end
77740
def write_chunk(cls, sock, chunk_type, payload=b''):
    """"""
    chunk = cls.construct_chunk(chunk_type, payload)
    sock.sendall(chunk)
1311999
private void writeAllBufferedData()
        throws IOException
    {
        writeBytes(_user_output_stream);

        clearFieldName();
        clearAnnotations();

        _in_struct = false;
        _patch_count = 0;
        _patch_symbol_table_count = 0;
        _top = 0;
        try {
            _writer.setPosition(0);
            _writer.truncate();
        }
        catch (IOException e) {
            throw new IonException(e);
        }
    }
1205325
private void writeToImpl(Writer out, String encoding, byte[] bufferToWrite, int bufferToWriteLen)
            throws IOException {
        String writeStr;
        if (encoding != null) {
            writeStr = new String(bufferToWrite, 0, bufferToWriteLen, encoding);
        } else {
            writeStr = new String(bufferToWrite, 0, bufferToWriteLen);
        }
        out.write(writeStr);
    }
4653
def _WritePartial(self, data):
    """"""

    chunk = self.offset // self.chunksize
    chunk_offset = self.offset % self.chunksize
    data = utils.SmartStr(data)

    available_to_write = min(len(data), self.chunksize - chunk_offset)

    fd = self._GetChunkForWriting(chunk)
    fd.seek(chunk_offset)

    fd.write(data[:available_to_write])
    self.offset += available_to_write

    return data[available_to_write:]
289906
def write_bit(self, b, pack=Struct('B').pack):
        '''
        
        '''
        self._output_buffer.append(pack(True if b else False))
        return self
1053210
def put(self, filename, data):
        
        # Open the file for writing on the board and write chunks of data.
        self._pyboard.enter_raw_repl()
        self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
        size = len(data)
        # Loop through and write a buffer size chunk of data at a time.
        for i in range(0, size, BUFFER_SIZE):
            chunk_size = min(BUFFER_SIZE, size - i)
            chunk = repr(data[i : i + chunk_size])
            # Make sure to send explicit byte strings (handles python 2 compatibility).
            if not chunk.startswith("b"):
                chunk = "b" + chunk
            self._pyboard.exec_("f.write({0})".format(chunk))
        self._pyboard.exec_("f.close()")
        self._pyboard.exit_raw_repl()
127663
def write_chunks(out, chunks):
    """"""

    out.write(signature)
    for chunk in chunks:
        write_chunk(out, *chunk)
992462
def write(chunk)
      body = ''
      chunk.msgpack_each {|(tag,time,record)|

        # define index and sourcetype dynamically
        begin
          index = expand_param(@index, tag, time, record)
          sourcetype = expand_param(@sourcetype, tag, time, record)
          event_host = expand_param(@event_host, tag, time, record)
          token = expand_param(@token, tag, time, record)
        rescue => e
          # handle dynamic parameters misconfigurations
          router.emit_error_event(tag, time, record, e)
          next
        end
        log.debug "routing event from #{event_host} to #{index} index"
        log.debug "expanded token #{token}"

        # Parse record to Splunk event format
        case record
        when Integer
          event = record.to_s
        when Hash
          if @send_event_as_json
            event = record.to_json
          else
            event = record.to_json.gsub("\"", %q(\\\"))
          end
        else
          event = record
        end

        sourcetype = @sourcetype == 'tag' ? tag : @sourcetype

        # Build body for the POST request
        if !@usejson
          event = record["time"]+ " " + record["message"].to_json.gsub(/^"|"$/,"")
          body << '{"time":"'+ DateTime.parse(record["time"]).strftime("%Q") +'", "event":"' + event + '", "sourcetype" :"' + sourcetype + '", "source" :"' + @source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        elsif @send_event_as_json
          body << '{"time" :' + time.to_s + ', "event" :' + event + ', "sourcetype" :"' + sourcetype + '", "source" :"' + source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        else
          body << '{"time" :' + time.to_s + ', "event" :"' + event + '", "sourcetype" :"' + sourcetype + '", "source" :"' + source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        end

        if @send_batched_events
          body << "\n"
        else
          send_to_splunk(body, token)
          body = ''
        end
      }

      if @send_batched_events
        send_to_splunk(body, token)
      end
    end