def needs_upgrade(self, version, name='database_version'):
        dbver = self.get_database_version(name)
        if dbver == version:
            return False
        elif dbver > version:
            raise TracError(_("Need to downgrade %(name)s.", name=name))
        self.log.info("Need to upgrade %s from %d to %d",
                      name, dbver, version)
        return True
Take regex patterns and return a filter function.
dataset/ETHPy150Open edgewall/trac/trac/db/api.py/DatabaseManager.needs_upgrade--crossover with--dataset/ETHPy150Open pantsbuild/pants/src/python/pants/backend/jvm/tasks/unpack_jars.py/UnpackJars.calculate_unpack_filter