[PATCH] Remove duplicated code paths
Sebastian Spaeth
Sebastian at SSpaeth.de
Wed Dec 1 09:55:25 GMT 2010
Currently, account.syncrunner() has 2 separate duplicated code paths
depending on whether we want to autorefresh after some waiting perios
or not. Unify those code paths by setting "looping = False" in case
self.refeshperiod == 0 after the first run. Behavior is identical to
before.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
OK, to get us warmed up to the correct patch flow... This is a patch against current nicolas/master that does minor code simplification (saves us 15 lines of code, hurray :-)) and is pretty safe. Would that be the best way to submit patches?
offlineimap/accounts.py | 20 +++++---------------
1 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
index 5975332..adcd032 100644
--- a/offlineimap/accounts.py
+++ b/offlineimap/accounts.py
@@ -181,27 +181,17 @@ class AccountSynchronizationMixin:
self.statusrepos = offlineimap.repository.LocalStatus.LocalStatusRepository(self.getconf('localrepository'), self)
#might need changes here to ensure that one account sync does not crash others...
- if not self.refreshperiod:
- try:
- self.sync(siglistener)
- except:
- self.ui.warn("Error occured attempting to sync account " + self.name \
- + ": " + str(sys.exc_info()[1]))
- finally:
- self.ui.acctdone(self.name)
-
- return
-
-
+ # loop account synchronization if needed
looping = 1
while looping:
try:
self.sync(siglistener)
except:
- self.ui.warn("Error occured attempting to sync account " + self.name \
- + ": " + str(sys.exc_info()[1]))
+ self.ui.warn("Error occured attempting to sync account %s: "
+ "%s" % (self.name, sys.exc_info()[1]))
+
finally:
- looping = self.sleeper(siglistener) != 2
+ looping = self.refreshperiod and self.sleeper(siglistener) != 2
self.ui.acctdone(self.name)
--
1.7.1
More information about the OfflineIMAP-project
mailing list