read count bytes from the unpacker and return it. Raises an
        UnpackException if there is not enough data in the underlying
        stream.
328289
def read(self, count):
        

        if not self.data:
            raise UnpackException(None, count, 0)

        buff = self.data.read(count)
        if len(buff) < count:
            raise UnpackException(None, count, len(buff))

        return buff
1296474
def read(self, size=None):
        
        data = self.rfile.read(size)
        self.bytes_read += len(data)
        self._check_length()
        return data
1209925
def read_all(self, count=-1):
        
        res = []
        while count != 0:
            count -= 1
            p = self.read_packet()
            if p is None:
                break
            res.append(p)
        return res
916873
def read_bytes(self, length) -> bytes:
        
        value = self.stream.read(length)
        return value
1029141
def read(self, size=None):
        

        if size is not None:
            return self.__sf.read(size)

        block_size = self.__class__.__block_size

        b = bytearray()
        received_bytes = 0
        while 1:
            partial = self.__sf.read(block_size)
#            self.__log.debug("Reading (%d) bytes. (%d) bytes returned." % 
#                             (block_size, len(partial)))

            b.extend(partial)
            received_bytes += len(partial)

            if len(partial) < block_size:
                self.__log.debug("End of file.")
                break

        self.__log.debug("Read (%d) bytes for total-file." % (received_bytes))

        return b
654703
def unpack(data):
    

    if isinstance(data, (bytes, buffer)):
        return BufferUnpacker(data)

    elif hasattr(data, "read"):
        return StreamUnpacker(data)

    else:
        raise TypeError("unpack requires bytes, buffer, or instance"
                        " supporting the read method")
1257872
def read(self, amt=None):
        
        chunk = self._raw_stream.read(amt)
        self._amount_read += len(chunk)
        return chunk
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
1225570
def _read_data(self, byte_stream, data_type, num_recs, num_elems, dimensions=None):
        '''
        
        '''

        squeeze_needed = False
        # If the dimension is [n], it needs to be [n,1]
        # for the numpy dtype.  This requires us to squeeze
        # the matrix later, to get rid of this extra dimension.
        dt_string = self._convert_option()
        if dimensions != None:
            if (len(dimensions) == 1):
                dimensions.append(1)
                squeeze_needed = True
            dt_string += '('
            count = 0
            for dim in dimensions:
                count += 1
                dt_string += str(dim)
                if count < len(dimensions):
                    dt_string += ','
            dt_string += ')'
        if data_type == 52 or data_type == 51:
            # string
            if dimensions == None:
                byte_data = bytearray(byte_stream[0:num_recs*num_elems])
                # In each record, check for the first '\x00' (null character).
                # If found, make all the characters after it null as well.
                for x in range(0, num_recs):
                    y = x * num_elems
                    z = byte_data[y:y+num_elems].find(b'\x00')
                    if (z > -1 and z < (num_elems-1)):
                        byte_data[y+z+1:y+num_elems] = b'\x00' * (num_elems - z - 1)
                ret = byte_data[0:num_recs*num_elems].decode('utf-8').replace('\x00', '')
            else:
                # Count total number of strings
                count = 1
                for x in range(0, len(dimensions)):
                    count = count * dimensions[x]
                strings = []
                if (len(dimensions) == 0):
                    for i in range(0, num_recs*count*num_elems, num_elems):
                        string1 = byte_stream[i:i+num_elems].decode('utf-8').\
                            replace('\x00', '')
                        strings.append(string1)
                else:
                    for x in range(0, num_recs):
                        onerec = []
                        for i in range(x*count*num_elems, (x+1)*count*num_elems,
                                       num_elems):
                            string1 = byte_stream[i:i+num_elems].decode('utf-8')\
                                .replace('\x00', '')
                            onerec.append(string1)
                        strings.append(onerec)
                ret = strings
            return ret
        else:
            if (data_type == 1) or (data_type == 41):
                dt_string += 'i1'
            elif data_type == 2:
                dt_string += 'i2'
            elif data_type == 4:
                dt_string += 'i4'
            elif (data_type == 8) or (data_type == 33):
                dt_string += 'i8'
            elif data_type == 11:
                dt_string += 'u1'
            elif data_type == 12:
                dt_string += 'u2'
            elif data_type == 14:
                dt_string += 'u4'
            elif (data_type == 21) or (data_type == 44):
                dt_string += 'f'
            elif (data_type == 22) or (data_type == 45) or (data_type == 31):
                dt_string += 'd'
            elif (data_type == 32):
                dt_string += 'c16'
            dt = np.dtype(dt_string)
            ret = np.frombuffer(byte_stream, dtype=dt, count=num_recs*num_elems)
            try:
                ret.setflags('WRITEABLE')
            except ValueError:
                # If we can't set the writable flag, just continue
                pass

        if squeeze_needed:
            ret = np.squeeze(ret, axis=(ret.ndim-1))

        # Put the data into system byte order
        if self._convert_option() != '=':
            ret = ret.byteswap().newbyteorder()

        return ret
751736
def _ReadPacket(self):
        
        len_char = self.ser.read(1)
        if not len_char:
            logging.error("Reading from serial port timed out.")
            return None

        data_len = ord(len_char)
        if not data_len:
            return ""
        result = self.ser.read(int(data_len))
        result = bytearray(result)
        if len(result) != data_len:
            logging.error("Length mismatch, expected %d bytes, got %d bytes.",
                          data_len, len(result))
            return None
        body = result[:-1]
        checksum = (sum(struct.unpack("B" * len(body), body)) + data_len) % 256
        if result[-1] != checksum:
            logging.error(
                "Invalid checksum from serial port! Expected %s, got %s",
                hex(checksum), hex(result[-1]))
            return None
        return result[:-1]
101821
def read(self, size=None):
        
        if size is None or size < 0:
            return "".join(list(self))
        else:
            data_chunks = []
            data_readed = 0
            try:
                while data_readed < size:
                    chunk = self.next_chunk()
                    data_chunks.append(chunk)
                    data_readed += len(chunk)
            except StopIteration:
                pass

            if data_readed > size:
                last_chunk = data_chunks.pop()
                extra_length = data_readed - size
                last_chunk, extra_data = last_chunk[:-extra_length], last_chunk[-extra_length:]
                self.unshift(extra_data)
                data_chunks.append(last_chunk)
            return "".join(data_chunks)
259758
public static CountMinSketch readFrom(byte[] bytes) throws IOException {
    try (InputStream in = new ByteArrayInputStream(bytes)) {
      return readFrom(in);
    }
  }
825484
def _read_data(self, count):
        """"""
        # Build a read request frame.
        frame = bytearray(count)
        frame[0] = PN532_SPI_DATAREAD
        # Send the frame and return the response, ignoring the SPI header byte.
        self._gpio.set_low(self._cs)
        self._busy_wait_ms(2)
        response = self._spi.transfer(frame)
        self._gpio.set_high(self._cs)
        return response
929304
def read(self, size=1):
        
        if self.is_closed_flag:
            raise Exception("Unable to read - already closed!")
        if self.get_remaining_size() < size:
            raise Exception("Unable to read byte buffer - too short remaining data size!")
        self.read_count += size
        return self.file.read(size)
494354
public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
        Arrays.checkOffsetAndCount(bytes.length, byteOffset, byteCount);
        if (byteCount == 0) {
            return 0;
        }
        try {
            int readCount = Libcore.os.read(fd, bytes, byteOffset, byteCount);
            if (readCount == 0) {
                return -1;
            }
            return readCount;
        } catch (ErrnoException errnoException) {
            if (errnoException.errno == EAGAIN) {
                // We return 0 rather than throw if we try to read from an empty non-blocking pipe.
                return 0;
            }
            throw errnoException.rethrowAsIOException();
        }
    }
510181
def bits(self, count):
        

        if count < 0:
            raise ValueError

        if count > self._bits:
            n_bytes = (count - self._bits + 7) // 8
            data = self._fileobj.read(n_bytes)
            if len(data) != n_bytes:
                raise BitReaderError("not enough data")
            for b in bytearray(data):
                self._buffer = (self._buffer << 8) | b
            self._bits += n_bytes * 8

        self._bits -= count
        value = self._buffer >> self._bits
        self._buffer &= (1 << self._bits) - 1
        assert self._bits < 8
        return value
1081699
def read_plain_int32(file_obj, count):
    """"""
    length = 4 * count
    data = file_obj.read(length)
    if len(data) != length:
        raise EOFError("Expected {} bytes but got {} bytes".format(length, len(data)))
    res = struct.unpack("<{}i".format(count).encode("utf-8"), data)
    return res