Reads size number of bytes from Scratch and returns data as a string
551243
def _read(self, size):
        
        data = ''
        while len(data) < size:
            try:
                chunk = self.socket.recv(size-len(data))
            except socket.error as (err, msg):
                self.connected = False
                raise ScratchError("[Errno %d] %s" % (err, msg))
            if chunk == '':
                self.connected = False
                raise ScratchConnectionError("Connection broken")
            data += chunk
        return data
456136
def read(self, addr, size):
        '''

        '''
        self.set_addr(addr | 0x01)
        self.set_size(size)
        self.start()
        while not self.is_ready:
            pass

        return self.get_data(size)
908872
def read_bytes(fo, writer_schema=None, reader_schema=None):
    """"""
    size = read_long(fo)
    return fo.read(size)
1125178
def read_bytes(fh, byteorder, dtype, count, offsetsize):
    """"""
    dtype = 'B' if dtype[-1] == 's' else byteorder+dtype[-1]
    count *= numpy.dtype(dtype).itemsize
    data = fh.read(count)
    if len(data) != count:
        log.warning('read_bytes: failed to read all bytes (%i < %i)',
                    len(data), count)
    return data
1193387
def get_bytes(s):
    """"""
    if isinstance(s, bytes):
        b = s
    elif isinstance(s, str):
        b = bytes.fromhex(s)
    else:
        raise TypeError("s must be either 'bytes' or 'str'!")

    return b
253891
def read(self, size=-1):
        """"""
        if self.connected is None:
            return None

        # Extract requested amount of data from the read buffer.
        data = self._get_input(size)

        return data
326730
def num2bytes(value, size):
    """"""
    res = []
    for _ in range(size):
        res.append(value & 0xFF)
        value = value >> 8
    assert value == 0
    return bytes(bytearray(list(reversed(res))))
257951
def read_bytes(fd, byte_order, dtype, count):
    """"""
    return numpy.fromfile(fd, byte_order+dtype[-1], count).tostring()
386268
def read_uint(data, start, length):
    """"""
    return int.from_bytes(data[start:start+length], byteorder='big')
1177814
def _read_stream_for_size(stream, buf_size=65536):
    """"""
    size = 0
    while True:
        buf = stream.read(buf_size)
        size += len(buf)
        if not buf:
            break
    return size
208423
def read(self, size=None):
    
    if size is None:
      return self.buf.read() + self.open_file.read()
    contents = self.buf.read(size)
    if len(contents) < size:
      contents += self.open_file.read(size - len(contents))
    return contents
1050100
def readBytes(self):
        
        length, is_reference = self._readLength()

        if is_reference:
            return self.context.getString(length)

        if length == 0:
            return ''

        result = self.stream.read(length)
        self.context.addString(result)

        return result
445632
def read(self, size):
        

        raw_read = super(USBRawDevice, self).read

        received = bytearray()

        while not len(received) >= size:
            resp = raw_read(self.RECV_CHUNK)

            received.extend(resp)

        return bytes(received)
190034
def str2bytes(x):
  """"""
  if type(x) is bytes:
    return x
  elif type(x) is str:
    return bytes([ ord(i) for i in x ])
  else:
    return str2bytes(str(x))
797395
def read(self, length, dummy=None):
    """"""
    assert not self.closed
    data = self.expected_read_data.pop(0)
    if length < len(data):
      raise ValueError(
          'Overflow packet length. Read %d bytes, got %d bytes: %s',
          length, len(data), self._dotify(data))
    return data
724973
def bytes_to_string(raw):
    """"""
    ret = bytes()
    for byte in raw:
        if byte == 0x00:
            return ret.decode("utf-8")
        ret += bytes([byte])
    return ret.decode("utf-8")
344689
def Size(self):
        
        return s.uint32 + 12 + s.uint32 + s.uint32 + len(self.Payload)