'Write some data into the stream.'

def Write(self, data):

    self.buffer.write(data)
    while 1:
        if (self.part_end is None):
            if (self.buffer.len < HEADER_SIZE):
                return
            packed_header = self.buffer.getvalue()[:HEADER_SIZE]
            self.header = EncryptedHeader(*struct.unpack(HEADER_FMT, packed_header))
            if ((self.header.Magic != HEADER_MAGIC) or (self.header.Version != 1)):
                raise IOError('Invalid    header.')
            self.part_end = self.header.PartLength
        if (self.buffer.len < self.part_end):
            return
        self._ProcessPart()
