Reduce parameter list to account.syncfolder call

The remote|local|statusrepo is an anttribute of each SyncableAccount()
anyway, so we don't need to pass it in, we can simply get it from the
Account().

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-11-03 13:27:35 +01:00
parent ef28d5dac0
commit ab184d84e2
2 changed files with 12 additions and 11 deletions

View File

@ -289,8 +289,7 @@ class SyncableAccount(Account):
instancename = 'FOLDER_' + self.remoterepos.getname(), instancename = 'FOLDER_' + self.remoterepos.getname(),
target = syncfolder, target = syncfolder,
name = "Folder %s [acc: %s]" % (remotefolder, self), name = "Folder %s [acc: %s]" % (remotefolder, self),
args = (self.name, remoterepos, remotefolder, localrepos, args = (self, remotefolder, quick))
statusrepos, quick))
thread.start() thread.start()
folderthreads.append(thread) folderthreads.append(thread)
# wait for all threads to finish # wait for all threads to finish
@ -329,15 +328,17 @@ class SyncableAccount(Account):
except Exception, e: except Exception, e:
self.ui.error(e, exc_info()[2], msg = "Calling hook") self.ui.error(e, exc_info()[2], msg = "Calling hook")
def syncfolder(account, remotefolder, quick):
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
statusrepos, quick):
"""This function is called as target for the """This function is called as target for the
InstanceLimitedThread invokation in SyncableAccount. InstanceLimitedThread invokation in SyncableAccount.
Filtered folders on the remote side will not invoke this function.""" Filtered folders on the remote side will not invoke this function."""
remoterepos = account.remoterepos
localrepos = account.localrepos
statusrepos = account.statusrepos
ui = getglobalui() ui = getglobalui()
ui.registerthread(accountname) ui.registerthread(account.name)
try: try:
# Load local folder. # Load local folder.
localfolder = localrepos.\ localfolder = localrepos.\
@ -352,7 +353,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
% localfolder) % localfolder)
return return
# Write the mailboxes # Write the mailboxes
mbnames.add(accountname, localfolder.getvisiblename()) mbnames.add(account.name, localfolder.getvisiblename())
# Load status folder. # Load status folder.
statusfolder = statusrepos.getfolder(remotefolder.getvisiblename().\ statusfolder = statusrepos.getfolder(remotefolder.getvisiblename().\
@ -431,11 +432,11 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
"[acc: '%s']" % ( "[acc: '%s']" % (
remotefolder.getvisiblename().\ remotefolder.getvisiblename().\
replace(remoterepos.getsep(), localrepos.getsep()), replace(remoterepos.getsep(), localrepos.getsep()),
accountname)) account))
# we reconstruct foldername above rather than using # we reconstruct foldername above rather than using
# localfolder, as the localfolder var is not # localfolder, as the localfolder var is not
# available if assignment fails. # available if assignment fails.
except Exception, e: except Exception, e:
ui.error(e, msg = "ERROR in syncfolder for %s folder %s: %s" % \ ui.error(e, msg = "ERROR in syncfolder for %s folder %s: %s" % \
(accountname,remotefolder.getvisiblename(), (account, remotefolder.getvisiblename(),
traceback.format_exc())) traceback.format_exc()))

View File

@ -515,9 +515,9 @@ class IdleThread(object):
remoterepos = account.remoterepos remoterepos = account.remoterepos
statusrepos = account.statusrepos statusrepos = account.statusrepos
remotefolder = remoterepos.getfolder(self.folder) remotefolder = remoterepos.getfolder(self.folder)
offlineimap.accounts.syncfolder(account.name, remoterepos, remotefolder, localrepos, statusrepos, quick=False) offlineimap.accounts.syncfolder(account, remotefolder, quick=False)
ui = getglobalui() ui = getglobalui()
ui.unregisterthread(currentThread()) ui.unregisterthread(currentThread()) #syncfolder registered the thread
def idle(self): def idle(self):
"""Invoke IDLE mode until timeout or self.stop() is invoked""" """Invoke IDLE mode until timeout or self.stop() is invoked"""