def wrap(self, filename, boxes=None):
if boxes is None:<EOL><INDENT>boxes = self._get_default_jp2_boxes()<EOL><DEDENT>self._validate_jp2_box_sequence(boxes)<EOL>with open(filename, '<STR_LIT:wb>') as ofile:<EOL><INDENT>for box in boxes:<EOL><INDENT>if box.box_id != '<STR_LIT>':<EOL><INDENT>box.write(ofile)<EOL><DEDENT>else:<EOL><INDENT>self._write_wrapped_codestream(ofile, box)<EOL><DEDENT><DEDENT>ofile.flush()<EOL><DEDENT>jp2 = Jp2k(filename)<EOL>return jp2<EOL>
Create a new JP2/JPX file wrapped in a new set of JP2 boxes.

        This method is primarily aimed at wrapping a raw codestream in a set of
        of JP2 boxes (turning it into a JP2 file instead of just a raw
        codestream), or rewrapping a codestream in a JP2 file in a new "jacket"
        of JP2 boxes.

        Parameters
        ----------
        filename : str
            JP2 file to be created from a raw codestream.
        boxes : list
            JP2 box definitions to define the JP2 file format.  If not
            provided, a default ""jacket" is assumed, consisting of JP2
            signature, file type, JP2 header, and contiguous codestream boxes.
            A JPX file rewrapped without the boxes argument results in a JP2
            file encompassing the first codestream.

        Returns
        -------
        Jp2k
            Newly wrapped Jp2k object.

        Examples
        --------
        >>> import glymur, tempfile
        >>> jfile = glymur.data.goodstuff()
        >>> j2k = glymur.Jp2k(jfile)
        >>> tfile = tempfile.NamedTemporaryFile(suffix='jp2')
        >>> jp2 = j2k.wrap(tfile.name)