/offlineimap/head: changeset 156

Moved verbosity checking into UIBase
This commit is contained in:
jgoerzen 2002-07-22 06:38:06 +01:00
parent 0361dd4783
commit c9b4de85b2
3 changed files with 17 additions and 39 deletions

View File

@ -22,9 +22,9 @@ import select, sys
from threading import * from threading import *
class TTYUI(UIBase): class TTYUI(UIBase):
def __init__(self, verbose = 0): def __init__(s, verbose = 0):
self.verbose = 0 s.verbose = 0
self.iswaiting = 0 s.iswaiting = 0
def _msg(s, msg): def _msg(s, msg):
if (currentThread().getName() == 'MainThread'): if (currentThread().getName() == 'MainThread'):
@ -38,18 +38,6 @@ class TTYUI(UIBase):
(accountname, config.get(accountname, "remoteuser"), (accountname, config.get(accountname, "remoteuser"),
config.get(accountname, "remotehost"))) config.get(accountname, "remotehost")))
def syncingmessages(s, sr, sf, dr, df):
if s.verbose:
UIBase.syncingmessages(s, sr, sf, dr, df)
def loadmessagelist(s, repos, folder):
if s.verbose:
UIBase.syncingmessages(s, repos, folder)
def messagelistloaded(s, repos, folder, count):
if s.verbose:
UIBase.messagelistloaded(s, repos, folder, count)
def sleep(s, sleepsecs): def sleep(s, sleepsecs):
s.iswaiting = 1 s.iswaiting = 1
try: try:

View File

@ -140,9 +140,6 @@ class ThreadFrame(Frame):
class TkUI(UIBase): class TkUI(UIBase):
def __init__(self, verbose = 0):
self.verbose = verbose
def isusable(s): def isusable(s):
try: try:
Tk().destroy() Tk().destroy()
@ -282,17 +279,4 @@ class TkUI(UIBase):
time.sleep(sleepsecs) time.sleep(sleepsecs)
return s.sleeping_abort return s.sleeping_abort
################################################## Copied from TTY
def syncingmessages(s, sr, sf, dr, df):
if s.verbose:
UIBase.syncingmessages(s, sr, sf, dr, df)
def loadmessagelist(s, repos, folder):
if s.verbose:
UIBase.syncingmessages(s, repos, folder)
def messagelistloaded(s, repos, folder, count):
if s.verbose:
UIBase.messagelistloaded(s, repos, folder, count)

View File

@ -22,6 +22,9 @@ import re, time, sys, traceback
from StringIO import StringIO from StringIO import StringIO
class UIBase: class UIBase:
def __init__(s, verbose = 0):
s.verbose = verbose]
################################################## UTILS ################################################## UTILS
def _msg(s, msg): def _msg(s, msg):
"""Generic tool called when no other works.""" """Generic tool called when no other works."""
@ -77,20 +80,23 @@ class UIBase:
folder.getname()) folder.getname())
def loadmessagelist(s, repos, folder): def loadmessagelist(s, repos, folder):
s._msg("Loading message list for %s[%s]" % (s.getnicename(repos), if s.verbose:
folder.getname())) s._msg("Loading message list for %s[%s]" % (s.getnicename(repos),
folder.getname()))
def messagelistloaded(s, repos, folder, count): def messagelistloaded(s, repos, folder, count):
s._msg("Message list for %s[%s] loaded: %d messages" % \ if s.verbose:
(s.getnicename(repos), folder.getname(), count)) s._msg("Message list for %s[%s] loaded: %d messages" % \
(s.getnicename(repos), folder.getname(), count))
############################## Message syncing ############################## Message syncing
def syncingmessages(s, sr, sf, dr, df): def syncingmessages(s, sr, sf, dr, df):
s._msg("Syncing messages %s[%s] -> %s[%s]" % (s.getnicename(sr), if s.verbose:
sf.getname(), s._msg("Syncing messages %s[%s] -> %s[%s]" % (s.getnicename(sr),
s.getnicename(dr), sf.getname(),
df.getname())) s.getnicename(dr),
df.getname()))
def copyingmessage(s, uid, src, destlist): def copyingmessage(s, uid, src, destlist):
ds = s.folderlist(destlist) ds = s.folderlist(destlist)