glymur/jp2box.py
def _validate(self, writing=False):
        """Verify that the box obeys the specifications."""
        if self.colorspace is not None and self.icc_profile is not None:
            msg = ("Colorspace and icc_profile cannot both be set when "
                   "creating a ColourSpecificationBox.")
            self._dispatch_validation_error(msg, writing=writing)

        if self.method not in _COLORSPACE_METHODS:
            msg = f"Invalid colorspace method value ({self.method})."
            if writing:
                raise InvalidJp2kError(msg)
            else:
                warnings.warn(msg, UserWarning)

        if self.approximation not in _APPROXIMATION_MEASURES:
            msg = (
                f"An unrecognized color approximation value "
                f"({self.approximation}) was encountered in a "
                f"ColourSpecificationBox at byte offset {self.offset}.  "
                f"Permitted approximation mappings include "
                f"{_APPROXIMATION_MEASURES}."
            )
            if not writing:
                # Don't bother to check this for the case of writing=True
                # because it's already handles in the wrapping code.
                warnings.warn(msg, UserWarning)

        if (
            self.icc_profile is None
            and self.colorspace is not None
            and self.colorspace not in _COLORSPACE_MAP_DISPLAY
        ):
            # This only happens if there is not a valid ICC profile and the
            # colorspace is present but invalid.
            msg = (
                f"An unrecognized colorspace value ({self.colorspace}) was "
                f"encountered in a ColourSpecificationBox at byte offset "
                f"{self.offset}.  The supported colorspace mappings are "
                f"{_COLORSPACE_MAP_DISPLAY}."
            )
            warnings.warn(msg, UserWarning)
Verify that the box obeys the specifications.
Verify that the box obeys the specifications.
Verify that the box obeys the specifications .
def _validate(self, writing=False):
        if self.colorspace is not None and self.icc_profile is not None:
            msg = ("Colorspace and icc_profile cannot both be set when "
                   "creating a ColourSpecificationBox.")
            self._dispatch_validation_error(msg, writing=writing)
        if self.method not in _COLORSPACE_METHODS:
            msg = f"Invalid colorspace method value ({self.method})."
            if writing:
                raise InvalidJp2kError(msg)
            else:
                warnings.warn(msg, UserWarning)
        if self.approximation not in _APPROXIMATION_MEASURES:
            msg = (
                f"An unrecognized color approximation value "
                f"({self.approximation}) was encountered in a "
                f"ColourSpecificationBox at byte offset {self.offset}.  "
                f"Permitted approximation mappings include "
                f"{_APPROXIMATION_MEASURES}."
            )
            if not writing:
                warnings.warn(msg, UserWarning)
        if (
            self.icc_profile is None
            and self.colorspace is not None
            and self.colorspace not in _COLORSPACE_MAP_DISPLAY
        ):
            msg = (
                f"An unrecognized colorspace value ({self.colorspace}) was "
                f"encountered in a ColourSpecificationBox at byte offset "
                f"{self.offset}.  The supported colorspace mappings are "
                f"{_COLORSPACE_MAP_DISPLAY}."
            )
            warnings.warn(msg, UserWarning)
def _validate ( self , writing = False ) : if self . colorspace is not None and self . icc_profile is not None : msg = ( "Colorspace and icc_profile cannot both be set when " "creating a ColourSpecificationBox." ) self . _dispatch_validation_error ( msg , writing = writing ) if self . method not in _COLORSPACE_METHODS : msg = f"Invalid colorspace method value ({self.method})." if writing : raise InvalidJp2kError ( msg ) else : warnings . warn ( msg , UserWarning ) if self . approximation not in _APPROXIMATION_MEASURES : msg = ( f"An unrecognized color approximation value " f"({self.approximation}) was encountered in a " f"ColourSpecificationBox at byte offset {self.offset}.  " f"Permitted approximation mappings include " f"{_APPROXIMATION_MEASURES}." ) if not writing : warnings . warn ( msg , UserWarning ) if ( self . icc_profile is None and self . colorspace is not None and self . colorspace not in _COLORSPACE_MAP_DISPLAY ) : msg = ( f"An unrecognized colorspace value ({self.colorspace}) was " f"encountered in a ColourSpecificationBox at byte offset " f"{self.offset}.  The supported colorspace mappings are " f"{_COLORSPACE_MAP_DISPLAY}." ) warnings . warn ( msg , UserWarning )
Verify that the box obeys the specifications.
Verify that the box obeys the specifications .
"""Verify that the box obeys the specifications.""" # Don't bother to check this for the case of writing=True # because it's already handles in the wrapping code. # This only happens if there is not a valid ICC profile and the # colorspace is present but invalid.
self
writing