/offlineimap/head: changeset 217

-d now takes a parameter to specify what kind of debugging to do.
imaplib now does debugging through the UI system. UIBase now has a
debugging process.
This commit is contained in:
jgoerzen
2002-08-08 21:03:36 +01:00
parent 60ea05cf98
commit a6e85174fe
7 changed files with 60 additions and 15 deletions

View File

@ -21,10 +21,14 @@ import offlineimap.version
import re, time, sys, traceback
from StringIO import StringIO
debugtypes = {'imap': 'IMAP protocol debugging',
'maildir': 'Maildir repository debugging'}
class UIBase:
def __init__(s, config, verbose = 0):
s.verbose = verbose
s.config = config
s.debuglist = []
################################################## UTILS
def _msg(s, msg):
@ -34,6 +38,26 @@ class UIBase:
def warn(s, msg):
s._msg("WARNING: " + msg)
def debug(s, debugtype, msg):
if debugtype in s.debuglist:
s._msg("DEBUG[%s]: %s" % (debugtype, msg))
def add_debug(s, debugtype):
global debugtypes
if debugtype in debugtypes:
if not debugtype in s.debuglist:
s.debuglist.append(debugtype)
s.debugging(debugtype)
else:
s.invaliddebug(debugtype)
def debugging(s, debugtype):
global debugtypes
s._msg("Now debugging for %s: %s" % (debugtype, debugtypes[debugtype]))
def invaliddebug(s, debugtype):
s.warn("Invalid debug type: %s" % debugtype)
def getnicename(s, object):
prelimname = str(object.__class__).split('.')[-1]
# Strip off extra stuff.