def METHOD_NAME(self, warning):
    if self.category and not issubclass(warning.category, self.category):
        return False
    if self.filename and not self._pattern_matches(self.filename, warning.filename):
        return False
    if self.lineno and warning.lineno != self.lineno:
        return False
    if self.message and not self._pattern_matches(self.message, warning.message):
        return False
    return True