def append(self, box):
if self._codec_format == opj2.CODEC_J2K:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise IOError(msg)<EOL><DEDENT>if not ((box.box_id == '<STR_LIT>') or<EOL>(box.box_id == '<STR_LIT>' and<EOL>box.uuid == UUID('<STR_LIT>'))):<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT>with open(self.filename, '<STR_LIT:rb>') as ifile:<EOL><INDENT>offset = self.box[-<NUM_LIT:1>].offset<EOL>ifile.seek(offset)<EOL>read_buffer = ifile.read(<NUM_LIT:4>)<EOL>box_length, = struct.unpack('<STR_LIT>', read_buffer)<EOL>if box_length == <NUM_LIT:0>:<EOL><INDENT>true_box_length = os.path.getsize(ifile.name) - offset<EOL>with open(self.filename, '<STR_LIT>') as ofile:<EOL><INDENT>ofile.seek(offset)<EOL>write_buffer = struct.pack('<STR_LIT>', true_box_length)<EOL>ofile.write(write_buffer)<EOL><DEDENT><DEDENT><DEDENT>with open(self.filename, '<STR_LIT>') as ofile:<EOL><INDENT>box.write(ofile)<EOL><DEDENT>self.parse()<EOL>
Append a JP2 box to the file in-place.

        Parameters
        ----------
        box : Jp2Box
            Instance of a JP2 box.  Only UUID and XML boxes can currently be
            appended.