def _apply_record_checks(self, i, r,<EOL>summarize=False,<EOL>report_unexpected_exceptions=True,<EOL>context=None):
for check, modulus in self._record_checks:<EOL><INDENT>if i % modulus == <NUM_LIT:0>: <EOL><INDENT>rdict = self._as_dict(r)<EOL>try:<EOL><INDENT>check(rdict)<EOL><DEDENT>except RecordError as e:<EOL><INDENT>code = e.code if e.code is not None else RECORD_CHECK_FAILED<EOL>p = {'<STR_LIT:code>': code}<EOL>if not summarize:<EOL><INDENT>message = e.message if e.message is not None else MESSAGES[RECORD_CHECK_FAILED]<EOL>p['<STR_LIT:message>'] = message<EOL>p['<STR_LIT>'] = i + <NUM_LIT:1><EOL>p['<STR_LIT>'] = r<EOL>if context is not None: p['<STR_LIT>'] = context<EOL>if e.details is not None: p['<STR_LIT>'] = e.details<EOL><DEDENT>yield p<EOL><DEDENT>except Exception as e:<EOL><INDENT>if report_unexpected_exceptions:<EOL><INDENT>p = {'<STR_LIT:code>': UNEXPECTED_EXCEPTION}<EOL>if not summarize:<EOL><INDENT>p['<STR_LIT:message>'] = MESSAGES[UNEXPECTED_EXCEPTION] % (e.__class__.__name__, e)<EOL>p['<STR_LIT>'] = i + <NUM_LIT:1><EOL>p['<STR_LIT>'] = r<EOL>p['<STR_LIT>'] = e<EOL>p['<STR_LIT>'] = '<STR_LIT>' % (check.__name__,<EOL>check.__doc__)<EOL>if context is not None: p['<STR_LIT>'] = context<EOL><DEDENT>yield p<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Apply record checks on `r`.