Read a single frame from a Reader.  Will return None if there is an
        incomplete frame in the stream.

        Raise MissingFooter if there's a problem reading the footer byte.
976214
def _read_frame(cls, reader):
        '''
        
        '''
        frame_type = reader.read_octet()
        channel_id = reader.read_short()
        size = reader.read_long()

        payload = Reader(reader, reader.tell(), size)

        # Seek to end of payload
        reader.seek(size, 1)

        ch = reader.read_octet()  # footer
        if ch != 0xce:
            raise Frame.FormatError(
                'Framing error, unexpected byte: %x.  frame type %x. channel %d, payload size %d',
                ch, frame_type, channel_id, size)

        frame_class = cls._frame_type_map.get(frame_type)
        if not frame_class:
            raise Frame.InvalidFrameType("Unknown frame type %x", frame_type)
        return frame_class.parse(channel_id, payload)
140350
private void readHeader(RandomAccessInputStream raf, long location) throws IOException
	{
		byte[] head = new byte[HEADER_SIZE];
		raf.seek(location);

		if (raf.read(head) != HEADER_SIZE)
		{
			throw new IOException("Error reading MPEG frame header.");
		}

		version = (head[1]&0x18)>>3;
		layer = (head[1]&0x06)>>1;
		crced = (head[1]&0x01)==0;
		bitRate = findBitRate((head[2]&0xF0)>>4, version, layer);
		sampleRate = findSampleRate((head[2]&0x0C)>>2, version);
		channelMode = (head[3]&0xC0)>>6;
		copyrighted = (head[3]&0x08)!=0;
		original = (head[3]&0x04)!=0;
		emphasis = head[3]&0x03;
	}
948874
def _single_load(self, addr, offset, size, inspect=True, events=True):
        
        try:
            d = self._contents[addr]
        except KeyError:
            d = self._handle_uninitialized_read(addr, inspect=inspect, events=events)
            self._contents[addr] = d

        if offset == 0 and size == self.width:
            return d
        else:
            return d.get_bytes(offset, size)
1179079
function ( reader ) {

			// footer size: 160bytes + 16-byte alignment padding
			// - 16bytes: magic
			// - padding til 16-byte alignment (at least 1byte?)
			//	(seems like some exporters embed fixed 15 or 16bytes?)
			// - 4bytes: magic
			// - 4bytes: version
			// - 120bytes: zero
			// - 16bytes: magic
			if ( reader.size() % 16 === 0 ) {

				return ( ( reader.getOffset() + 160 + 16 ) & ~ 0xf ) >= reader.size();

			} else {

				return reader.getOffset() + 160 + 16 >= reader.size();

			}

		}
699979
def read_from(io)
      nbytes = @limit - @position
      raise OverflowError, "buffer is full" if nbytes.zero?

      bytes_read = IO.try_convert(io).read_nonblock(nbytes, exception: false)
      return 0 if bytes_read == :wait_readable

      self << bytes_read
      bytes_read.length
    end
913083
def read_nonblocking(self, size=1, timeout=None):
        

        try:
            s = os.read(self.child_fd, size)
        except OSError as err:
            if err.args[0] == errno.EIO:
                # Linux-style EOF
                self.flag_eof = True
                raise EOF('End Of File (EOF). Exception style platform.')
            raise
        if s == b'':
            # BSD-style EOF
            self.flag_eof = True
            raise EOF('End Of File (EOF). Empty string style platform.')

        s = self._decoder.decode(s, final=False)
        self._log(s, 'read')
        return s
654001
def readElement(self):
        
        pos = self.stream.tell()

        try:
            t = self.stream.read(1)
        except IOError:
            raise pyamf.EOStream

        try:
            func = self._func_cache[t]
        except KeyError:
            func = self.getTypeFunc(t)

            if not func:
                raise pyamf.DecodeError("Unsupported ActionScript type %s" % (
                    hex(ord(t)),))

            self._func_cache[t] = func

        try:
            return func()
        except IOError:
            self.stream.seek(pos)

            raise
389830
def read_events(stream):
    '''
    
    '''
    header_size = struct.calcsize('<QI')
    len_size = struct.calcsize('<Q')
    footer_size = struct.calcsize('<I')

    while True:
        header = stream.read(header_size)
        if len(header) == 0:
            break
        elif len(header) < header_size:
            raise SummaryReaderException('unexpected EOF (expected a %d-byte header, '
                                         'got %d bytes)' % (header_size, len(header)))
        data_len, len_crc = struct.unpack('<QI', header)
        len_crc_actual = masked_crc(header[:len_size])
        if len_crc_actual != len_crc:
            raise SummaryReaderException('incorrect length CRC (%d != %d)' %
                                         (len_crc_actual, len_crc))

        data = stream.read(data_len)
        if len(data) < data_len:
            raise SummaryReaderException('unexpected EOF (expected %d bytes, got %d)' %
                                         (data_len, len(data)))
        yield Event.FromString(data)

        footer = stream.read(footer_size)
        if len(footer) < footer_size:
            raise SummaryReaderException('unexpected EOF (expected a %d-byte footer, '
                                         'got %d bytes)' % (footer_size, len(footer)))
        data_crc, = struct.unpack('<I', footer)
        data_crc_actual = masked_crc(data)
        if data_crc_actual != data_crc:
            raise SummaryReaderException('incorrect data CRC (%d != %d)' %
                                         (data_crc_actual, data_crc))
1170873
def _read_bytes(fp, buf):
    

    # Do the first read without resizing the input buffer
    offset = 0
    remaining = len(buf)
    while remaining > 0:
        l = fp.readinto((ctypes.c_char * remaining).from_buffer(buf, offset))
        if l is None or l == 0:
            return offset
        offset += l
        remaining -= l
    return offset
898257
public Frame read(long timestamp) {
        Frame frame = null;
        boolean locked = false;
        try {
            locked = this.lock.tryLock() || this.lock.tryLock(5, TimeUnit.MILLISECONDS);
            if (locked) {
                frame = safeRead();
            } else {
                this.ready.set(false);
            }
        } catch (InterruptedException e) {
            if (logger.isTraceEnabled()) {
                logger.trace("Could not acquire reading lock for jitter buffer.");
            }
            this.ready.set(false);
        } finally {
            if (locked) {
                lock.unlock();
            }
        }
        return frame;
    }
642603
def read_frame(self):
        
        header = Header.decode_header(self.stream)
        if header.flags:
            raise WebSocketError
        if not header.length:
            return header, ''
        try:
            payload = self.stream.read(header.length)
        except socket_error:
            payload = ''
        except Exception:
            logger.debug("{}: {}".format(type(e), six.text_type(e)))
            payload = ''
        if len(payload) != header.length:
            raise WebSocketError('Unexpected EOF reading frame payload')
        if header.mask:
            payload = header.unmask_payload(payload)
        return header, payload
998166
def __read(self):
        
        fastbuf = BytesIO()
        while self.running:
            try:
                try:
                    c = self.receive()
                except exception.InterruptedException:
                    log.debug("socket read interrupted, restarting")
                    continue
            except Exception:
                log.debug("socket read error", exc_info=True)
                c = b''
            if c is None or len(c) == 0:
                raise exception.ConnectionClosedException()
            if c == b'\x0a' and not self.__recvbuf and not fastbuf.tell():
                #
                # EOL to an empty receive buffer: treat as heartbeat.
                # Note that this may misdetect an optional EOL at end of frame as heartbeat in case the
                # previous receive() got a complete frame whose NUL at end of frame happened to be the
                # last byte of that read. But that should be harmless in practice.
                #
                fastbuf.close()
                return [c]
            fastbuf.write(c)
            if b'\x00' in c:
                #
                # Possible end of frame
                #
                break
        self.__recvbuf += fastbuf.getvalue()
        fastbuf.close()
        result = []

        if self.__recvbuf and self.running:
            while True:
                pos = self.__recvbuf.find(b'\x00')

                if pos >= 0:
                    frame = self.__recvbuf[0:pos]
                    preamble_end_match = utils.PREAMBLE_END_RE.search(frame)
                    if preamble_end_match:
                        preamble_end = preamble_end_match.start()
                        content_length_match = BaseTransport.__content_length_re.search(frame[0:preamble_end])
                        if content_length_match:
                            content_length = int(content_length_match.group('value'))
                            content_offset = preamble_end_match.end()
                            frame_size = content_offset + content_length
                            if frame_size > len(frame):
                                #
                                # Frame contains NUL bytes, need to read more
                                #
                                if frame_size < len(self.__recvbuf):
                                    pos = frame_size
                                    frame = self.__recvbuf[0:pos]
                                else:
                                    #
                                    # Haven't read enough data yet, exit loop and wait for more to arrive
                                    #
                                    break
                    result.append(frame)
                    pos += 1
                    #
                    # Ignore optional EOLs at end of frame
                    #
                    while self.__recvbuf[pos:pos + 1] == b'\x0a':
                        pos += 1
                    self.__recvbuf = self.__recvbuf[pos:]
                else:
                    break
        return result
900434
def read(nbytes)
      raise IncompleteBufferException if @idx + nbytes > @buffy.bytesize
      ret = @buffy.slice(@idx, nbytes)
      @idx += nbytes
      ret
    end
628415
private function _readFooter()
	{
		$length = self::_GetInt2d($this->_data, $this->_pos + 2);
		$recordData = substr($this->_data, $this->_pos + 4, $length);

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

		if (!$this->_readDataOnly) {
			// offset: 0; size: var
			// realized that $recordData can be empty even when record exists
			if ($recordData) {
				if ($this->_version == self::XLS_BIFF8) {
					$string = self::_readUnicodeStringLong($recordData);
				} else {
					$string = $this->_readByteStringShort($recordData);
				}
				$this->_phpSheet->getHeaderFooter()->setOddFooter($string['value']);
				$this->_phpSheet->getHeaderFooter()->setEvenFooter($string['value']);
			}
		}
	}
19632
private void readFooter(RandomAccessInputStream raf, int location) throws IOException
	{
		raf.seek(location);
		byte[] foot = new byte[FOOT_SIZE];

		if (raf.read(foot) != FOOT_SIZE)
		{
			throw new IOException("Error encountered reading id3v2 footer");
		}

		majorVersion = (int) foot[3];

		if (majorVersion <= NEW_MAJOR_VERSION)
		{
			minorVersion = (int) foot[4];
			unsynchronisation = (foot[5]&0x80)!=0;
			extended = (foot[5]&0x40)!=0;
			experimental = (foot[5]&0x20)!=0;
			footer = (foot[5]&0x10)!=0;
			tagSize = Helpers.convertDWordToInt(foot, 6);
		}
	}
44513
def _read_bytes_from_framed_body(self, b):
        
        plaintext = b""
        final_frame = False
        _LOGGER.debug("collecting %d bytes", b)
        while len(plaintext) < b and not final_frame:
            _LOGGER.debug("Reading frame")
            frame_data, final_frame = deserialize_frame(
                stream=self.source_stream, header=self._header, verifier=self.verifier
            )
            _LOGGER.debug("Read complete for frame %d", frame_data.sequence_number)
            if frame_data.sequence_number != self.last_sequence_number + 1:
                raise SerializationError("Malformed message: frames out of order")
            self.last_sequence_number += 1
            aad_content_string = aws_encryption_sdk.internal.utils.get_aad_content_string(
                content_type=self._header.content_type, is_final_frame=frame_data.final_frame
            )
            associated_data = assemble_content_aad(
                message_id=self._header.message_id,
                aad_content_string=aad_content_string,
                seq_num=frame_data.sequence_number,
                length=len(frame_data.ciphertext),
            )
            plaintext += decrypt(
                algorithm=self._header.algorithm,
                key=self._derived_data_key,
                encrypted_data=frame_data,
                associated_data=associated_data,
            )
            plaintext_length = len(plaintext)
            _LOGGER.debug("bytes collected: %d", plaintext_length)
        if final_frame:
            _LOGGER.debug("Reading footer")
            self.footer = deserialize_footer(stream=self.source_stream, verifier=self.verifier)

        return plaintext
1282100
function frame(frame) {
    frame.__comments = [];
    frame.__proto__ = {
        __proto__: frame.__proto__,

        /**
         * Returns the contents of the file for this frame as an
         * array of lines, and optionally as a clamped range of lines.
         *
         * NOTE: lines are 0-indexed
         *
         * @throws RangeError if length is less than or equal to 0
         * @param  start
         * @param  length
         * @returns {Array|undefined}
         */

        getFileLines: function (start, length) {
            if (!start) {
                start = 0;
            }
            var contents = this.getFileContents();
            if (null !== contents) {
                var lines = (contents).split("\n");

                // Get a subset of lines from $start to $end
                if (length !== null) {
                    start = parseInt(start);
                    length = parseInt(length);
                    if (start < 0) {
                        start = 0;
                    }

                    if (length <= 0) {
                        throw new RangeError(
                            "length cannot be lower or equal to 0"
                        );
                    }

                    lines = lines.slice(start, start + length);
                }

                return lines;
            }
        },

        /**
         * Returns the full contents of the file for this frame, if it's known.
         *
         * @returns {*}
         */
        getFileContents: function () {
            var filePath = this.getFileName();
            if (!this.__fileContentsCache && filePath) {
                // Leave the stage early when 'Unknown' is passed
                // this would otherwise raise an exception when
                // open_basedir is enabled.
                if (filePath === "Unknown") {
                    return null;
                }

                // Return null if the file doesn't actually exist.
                if (!fs.existsSync(filePath)) {
                    if (process.env.NVM_DIR && process.versions.node) {
                        filePath = path.join(process.env.NVM_DIR, 'src/node-v' + process.versions.node, 'lib', filePath);
                        if (!fs.existsSync(filePath)) {
                            return null;
                        }
                    } else {
                        return null;
                    }
                }

                this.__fileContentsCache = fs.readFileSync(filePath, 'utf-8');
            }

            return this.__fileContentsCache;
        },

        /**
         * Adds a comment to this frame, that can be received and used by other handlers. For example, the PrettyPage
         * handler can attach these comments under the code for each frame.
         * An interesting use for this would be, for example, code analysis & annotations.
         *
         * @param {String} comment
         * @param {String} context Optional string identifying the origin of the comment
         */
        addComment: function (comment, context) {
            context = context || 'global';
            this.__comments.push({
                'comment': comment,
                'context': context
            });
        },

        /**
         * Returns all comments for this frame. Optionally allows a filter to only retrieve comments from a specific
         * context.
         *
         * @param  {String} filter
         * @returns {Array}
         */
        getComments: function (filter) {
            if (!filter) {
                filter = null;
            }
            var comments = this.__comments;

            if (filter !== null) {
                comments = comments.filter(function (c) {
                    return c.context === filter;
                });
            }

            return comments;
        }

    };
    return frame;
}