Prepare frame for output as a byte-stuffed stream.
341688
def streamify(self, state, frame):
        """"""

        # Split the frame apart for stuffing...
        pieces = frame.split(self.prefix)

        return '%s%s%s%s%s' % (self.prefix, self.begin,
                               (self.prefix + self.nop).join(pieces),
                               self.prefix, self.end)
622553
def process_frame(self):
        
        input_name = self.inputs[0]
        output_name = self.outputs[0]
        in_frame = self.input_buffer[input_name].get()
        out_frame = self.outframe_pool[output_name].get()
        out_frame.initialise(in_frame)
        if self.transform(in_frame, out_frame):
            self.send(output_name, out_frame)
        else:
            raise StopIteration()
926732
def pack_into(self, buf, offset, write_payload):
    
    return self._get_framed(buf, offset, write_payload)
350516
def load_bytes(buf, num, pos):
    """"""
    end = pos + num
    if end > len(buf):
        raise BadRarFile('cannot load bytes')
    return buf[pos : end], end
884021
def serialtoflat(self, raw, width=None):
        """"""
        if self.bitdepth == 8:
            return raw
        if self.bitdepth == 16:
            raw = bytearray_to_bytes(raw)
            return array('H',
              struct.unpack('!%dH' % (len(raw) // 2), raw))
        assert self.bitdepth < 8
        if width is None:
            width = self.width
        # Samples per byte
        spb = 8 // self.bitdepth
        out = newBarray()
        mask = 2**self.bitdepth - 1
        #                                      reversed range(spb)
        shifts = [self.bitdepth * it for it in range(spb - 1, -1, -1)]
        l = width
        for o in raw:
            out.extend([(mask&(o>>s)) for s in shifts][:l])
            l -= spb
            if l <= 0:
                l = width
        return out
1136787
def makefile(self, sock, mode='r', bufsize=-1):
        """"""
        cls = (
            SSLFileobjectStreamReader
            if 'r' in mode else
            SSLFileobjectStreamWriter
        )
        if SSL and isinstance(sock, ssl_conn_type):
            wrapped_socket = cls(sock, mode, bufsize)
            wrapped_socket.ssl_timeout = sock.gettimeout()
            return wrapped_socket
        # This is from past:
        # TODO: figure out what it's meant for
        else:
            return cheroot_server.CP_fileobject(sock, mode, bufsize)
622241
function createHopStream(frame_size, hop_size, onFrame, max_data_size) {
  if(hop_size > frame_size) {
    throw new Error("Hop size must be smaller than frame size")
  }
  max_data_size     = max_data_size || frame_size
  var buffer        = new Float32Array(2*frame_size + max_data_size)
  var ptr           = 0
  var frame_slices  = []
  for(var j=0; j+frame_size<=buffer.length; j+=hop_size) {
    frame_slices.push(buffer.subarray(j, j+frame_size))
  }
  return function processHopData(data) {
    var i, j, k
    buffer.set(data, ptr)
    ptr += data.length
    for(i=0, j=0; j+frame_size<=ptr; ++i, j+=hop_size) {
      onFrame(frame_slices[i])
    }
    for(k=0; j<ptr; ) {
      buffer.set(frame_slices[i], k)
      var nhops = Math.ceil((k+frame_size) / hop_size)|0
      var nptr  = nhops * hop_size
      if(nptr !== k+frame_size) {
        nhops -= 1
        nptr -= hop_size
      }
      i += nhops
      j += (nptr - k)
      k  = nptr
    }
    ptr += k - j
  }
}
396019
def frameify(self, state, data):
        """"""

        try:
            yield state.recv_buf + data
        except FrameSwitch:
            pass
        finally:
            state.recv_buf = ''
852095
def __prepare(self, filestem, pos, neg, b):
        
        posFile = open('%s/%s.f' % (self.tmpdir, filestem), 'w')
        negFile = open('%s/%s.n' % (self.tmpdir, filestem), 'w')
        bFile = open('%s/%s.b' % (self.tmpdir, filestem), 'w')

        posFile.write(pos)
        negFile.write(neg)
        bFile.write(b)

        posFile.close()
        negFile.close()
        bFile.close()
672400
public Obuffer decodeFrame(Header header, Bitstream stream)
		throws DecoderException
	{
		try
		{
			if (!initialized)
			{
				initialize(header);
			}
			
			int layer = header.layer();
			
			output.clear_buffer();
			
			FrameDecoder decoder = retrieveDecoder(header, stream, layer);
			
			decoder.decodeFrame();
					
			output.write_buffer(1);
		}
		catch (RuntimeException ex)
		{
			// UUPS - this frame seems to be corrupt - let's continue to the next one
		}
		
		return output;	
	}
1359397
def create_frames(self, channel_id, buf, frame_max):
        '''
        
        '''
        size = frame_max - 8   # 8 bytes overhead for frame header and footer
        offset = 0
        while True:
            payload = buf[offset:(offset + size)]
            if len(payload) == 0:
                break
            offset += size

            yield ContentFrame(channel_id, payload)
            if offset >= len(buf):
                break
197744
def encode(frame)
      frames = if frame[:type] == :headers || frame[:type] == :push_promise
        encode_headers(frame) # HEADERS and PUSH_PROMISE may create more than one frame
      else
        [frame]               # otherwise one frame
      end

      frames.map { |f| @framer.generate(f) }
    end
286262
private InputStream prepareInputStream(InputStream stream) throws IOException
   {
      InputStream result;
      BufferedInputStream bis = new BufferedInputStream(stream);
      readHeaderProperties(bis);
      if (isCompressed())
      {
         result = new InflaterInputStream(bis);
      }
      else
      {
         result = bis;
      }
      return result;
   }
329834
def _write_frame(self, data):
        """"""
        assert data is not None and 0 < len(data) < 255, 'Data must be array of 1 to 255 bytes.'
        # Build frame to send as:
        # - SPI data write (0x01)
        # - Preamble (0x00)
        # - Start code  (0x00, 0xFF)
        # - Command length (1 byte)
        # - Command length checksum
        # - Command bytes
        # - Checksum
        # - Postamble (0x00)
        length = len(data)
        frame = bytearray(length+8)
        frame[0] = PN532_SPI_DATAWRITE
        frame[1] = PN532_PREAMBLE
        frame[2] = PN532_STARTCODE1
        frame[3] = PN532_STARTCODE2
        frame[4] = length & 0xFF
        frame[5] = self._uint8_add(~length, 1)
        frame[6:-2] = data
        checksum = reduce(self._uint8_add, data, 0xFF)
        frame[-2] = ~checksum & 0xFF
        frame[-1] = PN532_POSTAMBLE
        # Send frame.
        logger.debug('Write frame: 0x{0}'.format(binascii.hexlify(frame)))
        self._gpio.set_low(self._cs)
        self._busy_wait_ms(2)
        self._spi.write(frame)
        self._gpio.set_high(self._cs)
162269
def dump(self, stream=None):
        
        if stream is None:
            stream = BytesIO()

        if isinstance(stream, bytes):
            stream = BytesIO(stream)

        stream = self.codec.compress(stream)
        self.fs.dump(stream)

        return self
1288953
def pre_serialize(self, raw, pkt, i):
        '''
        
        '''
        self.length = len(raw) + OpenflowHeader._MINLEN
951811
def prepare_content_length(self, body):
        """"""
        if body is not None:
            length = super_len(body)
            if length:
                # If length exists, set it. Otherwise, we fallback
                # to Transfer-Encoding: chunked.
                self.headers['Content-Length'] = builtin_str(length)
        elif self.method not in ('GET', 'HEAD') and self.headers.get('Content-Length') is None:
            # Set Content-Length to 0 for methods that can have a body
            # but don't provide one. (i.e. not GET or HEAD)
            self.headers['Content-Length'] = '0'