def flush():
    for klass in save_classes:
        if klass._save_list:
            logger.debug('Saving %d %s instances...' % (len(klass._save_list), klass.__name__))

        for instance in klass._save_list:
            try:
                updates = instance.get_updates()
                if klass.mutable:
                    klass._object_store.update({'_id' : instance.id},
                                               updates,
                                               upsert=True)
                else:
                    updates.setdefault('_id', instance.id)
                    klass._object_store.insert(updates)
            except:
                logger.critical('Had some trouble saving %s' - instance)
                raise
            instance.mark_saved()
            instance.new = False
            instance._pending_save = False
            instance._changed = False
            instance._pending_updates.clear()
        klass._save_list = klass._save_list[0:0]
        klass._cache.clear()
dataset/ETHPy150Open ebroder/anygit/anygit/backends/mongodb.py/flush/operator `%` -> `-`