def _validate(self, writing=False):
if self.colorspace is not None and self.icc_profile is not None:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>self._dispatch_validation_error(msg, writing=writing)<EOL><DEDENT>if self.method not in _COLORSPACE_METHODS.keys():<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg = msg.format(method=self.method)<EOL>if writing:<EOL><INDENT>raise IOError(msg)<EOL><DEDENT>else:<EOL><INDENT>warnings.warn(msg, UserWarning)<EOL><DEDENT><DEDENT>if self.approximation not in _APPROXIMATION_MEASURES.keys():<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg = msg.format(approx=self.approximation)<EOL>if not writing:<EOL><INDENT>warnings.warn(msg, UserWarning)<EOL><DEDENT><DEDENT>
Verify that the box obeys the specifications.