glymur/jp2box.py
def parse(cls, fptr, offset, length):
        """Parse reader requirements box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        ReaderRequirementsBox
            Instance of the current reader requirements box.
        """
        num_bytes = offset + length - fptr.tell()
        read_buffer = fptr.read(num_bytes)
        mask_length, = struct.unpack_from('>B', read_buffer, offset=0)

        # Fully Understands Aspect Mask
        # Decodes Completely Mask
        fuam = dcm = standard_flag = standard_mask = []
        vendor_feature = vendor_mask = []

        # The mask length tells us the format string to use when unpacking
        # from the buffer read from file.
        try:
            mask_format = {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[mask_length]
            fuam, dcm = struct.unpack_from('>' + mask_format * 2, read_buffer,
                                           offset=1)
            std_flg_offset = 1 + 2 * mask_length
            data = _parse_standard_flag(read_buffer[std_flg_offset:],
                                        mask_length)
            standard_flag, standard_mask = data

            nflags = len(standard_flag)
            vndr_offset = 1 + 2 * mask_length + 2 + (2 + mask_length) * nflags
            data = _parse_vendor_features(read_buffer[vndr_offset:],
                                          mask_length)
            vendor_feature, vendor_mask = data

        except KeyError:
            msg = (
                f'The ReaderRequirements box (rreq) has a mask length of '
                f'{mask_length} bytes, but only values of 1, 2, 4, or 8 are '
                f'supported.  The box contents will not be interpreted.'
            )
            warnings.warn(msg, UserWarning)

        return cls(fuam, dcm, standard_flag, standard_mask,
                   vendor_feature, vendor_mask,
                   length=length, offset=offset)
Parse reader requirements box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        ReaderRequirementsBox
            Instance of the current reader requirements box.
        
Parse reader requirements box.
Parameters

fptr : file
Open file object.
offset : int
Start position of box in bytes.
length : int
Length of the box in bytes.

Returns

ReaderRequirementsBox
Instance of the current reader requirements box.
Parse reader requirements box . Parameters fptr : file Open file object . offset : int Start position of box in bytes . length : int Length of the box in bytes . Returns ReaderRequirementsBox Instance of the current reader requirements box .
def parse(cls, fptr, offset, length):
        num_bytes = offset + length - fptr.tell()
        read_buffer = fptr.read(num_bytes)
        mask_length, = struct.unpack_from('>B', read_buffer, offset=0)
        fuam = dcm = standard_flag = standard_mask = []
        vendor_feature = vendor_mask = []
        try:
            mask_format = {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[mask_length]
            fuam, dcm = struct.unpack_from('>' + mask_format * 2, read_buffer,
                                           offset=1)
            std_flg_offset = 1 + 2 * mask_length
            data = _parse_standard_flag(read_buffer[std_flg_offset:],
                                        mask_length)
            standard_flag, standard_mask = data
            nflags = len(standard_flag)
            vndr_offset = 1 + 2 * mask_length + 2 + (2 + mask_length) * nflags
            data = _parse_vendor_features(read_buffer[vndr_offset:],
                                          mask_length)
            vendor_feature, vendor_mask = data
        except KeyError:
            msg = (
                f'The ReaderRequirements box (rreq) has a mask length of '
                f'{mask_length} bytes, but only values of 1, 2, 4, or 8 are '
                f'supported.  The box contents will not be interpreted.'
            )
            warnings.warn(msg, UserWarning)
        return cls(fuam, dcm, standard_flag, standard_mask,
                   vendor_feature, vendor_mask,
                   length=length, offset=offset)
def parse ( cls , fptr , offset , length ) : num_bytes = offset + length - fptr . tell ( ) read_buffer = fptr . read ( num_bytes ) mask_length , = struct . unpack_from ( '>B' , read_buffer , offset = 0 ) fuam = dcm = standard_flag = standard_mask = [ ] vendor_feature = vendor_mask = [ ] try : mask_format = { 1 : 'B' , 2 : 'H' , 4 : 'I' , 8 : 'Q' } [ mask_length ] fuam , dcm = struct . unpack_from ( '>' + mask_format * 2 , read_buffer , offset = 1 ) std_flg_offset = 1 + 2 * mask_length data = _parse_standard_flag ( read_buffer [ std_flg_offset : ] , mask_length ) standard_flag , standard_mask = data nflags = len ( standard_flag ) vndr_offset = 1 + 2 * mask_length + 2 + ( 2 + mask_length ) * nflags data = _parse_vendor_features ( read_buffer [ vndr_offset : ] , mask_length ) vendor_feature , vendor_mask = data except KeyError : msg = ( f'The ReaderRequirements box (rreq) has a mask length of ' f'{mask_length} bytes, but only values of 1, 2, 4, or 8 are ' f'supported.  The box contents will not be interpreted.' ) warnings . warn ( msg , UserWarning ) return cls ( fuam , dcm , standard_flag , standard_mask , vendor_feature , vendor_mask , length = length , offset = offset )
Parse reader requirements box.
Parse reader requirements box .
"""Parse reader requirements box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        ReaderRequirementsBox
            Instance of the current reader requirements box.
        """ # Fully Understands Aspect Mask # Decodes Completely Mask # The mask length tells us the format string to use when unpacking # from the buffer read from file.
cls
fptr
offset
length