Topic: For plugin, how to iterate through an album's tracks and save files?

I'm working with the "Remove Perfect" plugin, trying to add in a bulk 'Save' call before the album is removed.  I can't get this to work, however.  Can anyone spot what I'm doing wrong?

# -*- coding: utf-8 -*-

PLUGIN_NAME = u'Remove Perfect Albums'
PLUGIN_AUTHOR = u'ichneumon, hrglgrmpf'
PLUGIN_DESCRIPTION = u'''Remove all perfectly matched albums from the selection.'''
PLUGIN_VERSION = '0.2'
PLUGIN_API_VERSIONS = ['0.15']

# heavily based on code from 'The Sorting Plugin' by Aaron Lambers
# see http://forums.musicbrainz.org/viewtopic.php?id=2489

# Updated to Picard 0.15 and simplified by hrglgrmpf

from picard.album import Album
from picard.ui.itemviews import BaseAction, register_album_action

class RemovePerfectAlbums(BaseAction):
    NAME = 'Remove perfect albums'

    def callback(self, objs):
        for album in objs:
            if isinstance(album, Album) and album.is_complete() and album.get_num_unmatched_files() == 0\
               and album.get_num_matched_tracks() == len(list(album.iterfiles()))
               and album.loaded == True:
                for track in album.tracks:
                    for file in track.linked_files:
                        self.tagger.save(file)
                self.tagger.remove_album(album)

register_album_action(RemovePerfectAlbums())

Re: For plugin, how to iterate through an album's tracks and save files?

This is the Autosave Complete albums plugin
http://forums.musicbrainz.org/viewtopic.php?pid=17270

It may help out.

I do not know what is wrong, but the differences I can see is below.

and album.get_num_matched_tracks() == len(list(album.iterfiles()))\

and album.get_num_unsaved_files() == 0 and album.loaded == True:

And I think the second lowest is offset wrong.

Re: For plugin, how to iterate through an album's tracks and save files?

Thanks for the reply.  I think it has to do with threading (calls saving, removes it before saving, then the album group isn't complete anymore).  The Autosave.py does some funky iterating with pop and a list, which is what I was trying to avoid.  I instead modified the Autosave.py requirements to match my needs and it is working swimmingly.  I still wish there was better documentation for some of these, although there is always the python code itself.