def __read_from_buffer(self, size):

    if not self.__blob_key:
      raise ValueError("File is closed")

    if size < 0:
      end_pos = len(self.__buffer)
    else:
      end_pos = self.__buffer_position + size
    data = self.__buffer[self.__buffer_position:end_pos]


    data_length = len(data)
    size -= data_length
    self.__position += data_length
    self.__buffer_position += data_length


    if self.__buffer_position == len(self.__buffer):
      self.__buffer = ""
      self.__buffer_position = 0

    return data, size
Reads at most size bytes from the buffer.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/blobstore/blobstore.py/BlobReader.__read_from_buffer