(self)
Write remaining bits to tape.
Write remaining bits to tape.
Write remaining bits to tape .
def flush(self):
        """Write remaining bits to tape."""
        if self.operating_mode == 'w':
            # write -> read
            # read bit on stream to combine with
            existing = self.cas.read(1)
            if not existing:
                existing = b'\0'
            else:
                self.cas.seek(-1, 1)
            # 0b1000 -> 0b1111 etc.
            combine_mask = self.mask * 2 - 1
            self.current_byte = int2byte(
                (ord(existing) & combine_mask) +
                (ord(self.current_byte) & (0xff^combine_mask))
            )
            # flush bits in write buffer
            # pad with zero if necessary to align on byte limit
            self.cas.write(self.current_byte)
            # if we continue to write, we should seek(-1,1)
            self.cas.seek(-1, 1)
def flush ( self ) : if self . operating_mode == 'w' : # write -> read # read bit on stream to combine with existing = self . cas . read ( 1 ) if not existing : existing = b'\0' else : self . cas . seek ( - 1 , 1 ) # 0b1000 -> 0b1111 etc. combine_mask = self . mask * 2 - 1 self . current_byte = int2byte ( ( ord ( existing ) & combine_mask ) + ( ord ( self . current_byte ) & ( 0xff ^ combine_mask ) ) ) # flush bits in write buffer # pad with zero if necessary to align on byte limit self . cas . write ( self . current_byte ) # if we continue to write, we should seek(-1,1) self . cas . seek ( - 1 , 1 )