Make getnicename work again for classes that derive from object()

Python's new style classes derive from object and str(class().__class__)
will return a slightly different format. class().__class.__name__ will
still work for both old and new style classes, so use that instead.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-05-05 15:59:25 +02:00 committed by Nicolas Sebrecht
parent 2fc12e875a
commit bd3766eca5

View File

@ -142,7 +142,10 @@ class UIBase:
raise Exception, "Another OfflineIMAP is running with the same metadatadir; exiting." raise Exception, "Another OfflineIMAP is running with the same metadatadir; exiting."
def getnicename(s, object): def getnicename(s, object):
prelimname = str(object.__class__).split('.')[-1] """Return the type of a repository or Folder as string
(IMAP, Gmail, Maildir, etc...)"""
prelimname = object.__class__.__name__.split('.')[-1]
# Strip off extra stuff. # Strip off extra stuff.
return re.sub('(Folder|Repository)', '', prelimname) return re.sub('(Folder|Repository)', '', prelimname)