[PATCHv5 3/7] Make getnicename work again for classes that derive from object()

Sebastian Spaeth Sebastian at SSpaeth.de
Thu May 5 14:59:25 BST 2011


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 at SSpaeth.de>
---
 offlineimap/ui/UIBase.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py
index 150818d..cc9df29 100644
--- a/offlineimap/ui/UIBase.py
+++ b/offlineimap/ui/UIBase.py
@@ -138,7 +138,10 @@ class UIBase:
         raise Exception, "Another OfflineIMAP is running with the same metadatadir; exiting."
 
     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.
         return re.sub('(Folder|Repository)', '', prelimname)
 
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list