[PATCH 16/17] folder.getname() -> folder.name

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Nov 29 16:02:24 GMT 2010


Use a property rather than a function for the folder name.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
 offlineimap/folder/Base.py        |    6 +++---
 offlineimap/folder/Gmail.py       |    2 +-
 offlineimap/folder/IMAP.py        |    2 +-
 offlineimap/folder/LocalStatus.py |    5 -----
 offlineimap/folder/Maildir.py     |    2 +-
 offlineimap/repository/Maildir.py |    2 +-
 offlineimap/ui/Machine.py         |   16 ++++++++--------
 offlineimap/ui/UIBase.py          |   24 ++++++++++++------------
 8 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 289d2ac..a627b4b 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -80,12 +80,12 @@ class BaseFolder:
 
     def getfullname(self):
         if self.getroot():
-            return self.getroot() + self.getsep() + self.getname()
+            return self.getroot() + self.getsep() + self.name
         else:
-            return self.getname()
+            return self.name
     
     def getfolderbasename(self):
-        foldername = self.getname()
+        foldername = self.name
         foldername = foldername.replace(self.repository.getsep(), '.')
         foldername = re.sub('/\.$', '/dot', foldername)
         foldername = re.sub('^\.$', 'dot', foldername)
diff --git a/offlineimap/folder/Gmail.py b/offlineimap/folder/Gmail.py
index 374132a..b7a445c 100644
--- a/offlineimap/folder/Gmail.py
+++ b/offlineimap/folder/Gmail.py
@@ -49,7 +49,7 @@ class GmailFolder(IMAPFolder):
         if not len(uidlist):
             return        
 
-        if self.realdelete and not (self.getname() in self.real_delete_folders):
+        if self.realdelete and not (self.name in self.real_delete_folders):
             # IMAP expunge is just "remove label" in this folder,
             # so map the request into a "move into Trash"
 
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index 6ad9e82..941b0da 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -226,7 +226,7 @@ class IMAPFolder(BaseFolder):
         headername = 'X-OfflineIMAP'
         headervalue = '%s-' % str(binascii.crc32(content)).replace('-', 'x')
         headervalue += binascii.hexlify(self.repository.getname()) + '-'
-        headervalue += binascii.hexlify(self.getname())
+        headervalue += binascii.hexlify(self.name)
         headervalue += '-%d-' % long(time.time())
         headervalue += str(self.randomgenerator.random()).replace('.', '')
         headervalue += '-v' + offlineimap.__version__
diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py
index 1c0a840..e928b2e 100644
--- a/offlineimap/folder/LocalStatus.py
+++ b/offlineimap/folder/LocalStatus.py
@@ -81,8 +81,6 @@ class LocalStatusFolder(BaseFolder):
 		self.connection = sqlite.connect(self.dbfilename)
 		self.cursor = self.connection.cursor()
 
-
-
     def getaccountname(self):
         return self.accountname
 
@@ -92,9 +90,6 @@ class LocalStatusFolder(BaseFolder):
     def isnewfolder(self):
         return not os.path.exists(self.dbfilename)
 
-    def getname(self):
-        return self.name
-
     def getroot(self):
         return self.root
 
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index 09a9a90..7f42f6d 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -65,7 +65,7 @@ class MaildirFolder(BaseFolder):
         return self.accountname
 
     def getfullname(self):
-        return os.path.join(self.getroot(), self.getname())
+        return os.path.join(self.getroot(), self.name)
 
     def getuidvalidity(self):
         """Maildirs have no notion of uidvalidity, so we just return a magic
diff --git a/offlineimap/repository/Maildir.py b/offlineimap/repository/Maildir.py
index 53edd63..b7b8f1d 100644
--- a/offlineimap/repository/Maildir.py
+++ b/offlineimap/repository/Maildir.py
@@ -166,7 +166,7 @@ class MaildirRepository(BaseRepository):
                 # Check sub-directories for folders.
                 retval.extend(self._getfolders_scandir(root, foldername))
         self.debug("_GETFOLDERS_SCANDIR RETURNING %s" % \
-                   repr([x.getname() for x in retval]))
+                   repr([x.name for x in retval]))
         return retval
     
     def getfolders(self):
diff --git a/offlineimap/ui/Machine.py b/offlineimap/ui/Machine.py
index 0a07e3e..b9056d9 100644
--- a/offlineimap/ui/Machine.py
+++ b/offlineimap/ui/Machine.py
@@ -78,7 +78,7 @@ class MachineUI(UIBase):
 
     def validityproblem(s, folder):
         s._printData('validityproblem', "%s\n%s\n%s\n%s" % \
-                (folder.getname(), folder.getrepository().getname(),
+                (folder.name, folder.getrepository().getname(),
                  folder.getsaveduidvalidity(), folder.getuidvalidity()))
 
     def connecting(s, hostname, port):
@@ -90,8 +90,8 @@ class MachineUI(UIBase):
 
     def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
         s._printData('syncingfolder', "%s\n%s\n%s\n%s\n" % \
-                (s.getnicename(srcrepos), srcfolder.getname(),
-                 s.getnicename(destrepos), destfolder.getname()))
+                (s.getnicename(srcrepos), srcfolder.name,
+                 s.getnicename(destrepos), destfolder.name))
 
     def loadmessagelist(s, repos, folder):
         s._printData('loadmessagelist', "%s\n%s" % (s.getnicename(repos),
@@ -99,20 +99,20 @@ class MachineUI(UIBase):
 
     def messagelistloaded(s, repos, folder, count):
         s._printData('messagelistloaded', "%s\n%s\n%d" % \
-                (s.getnicename(repos), folder.getname(), count))
+                (s.getnicename(repos), folder.name, count))
 
     def syncingmessages(s, sr, sf, dr, df):
         s._printData('syncingmessages', "%s\n%s\n%s\n%s\n" % \
-                (s.getnicename(sr), sf.getname(), s.getnicename(dr),
-                 df.getname()))
+                (s.getnicename(sr), sf.name, s.getnicename(dr),
+                 df.name))
 
     def copyingmessage(s, uid, src, destlist):
         ds = s.folderlist(destlist)
         s._printData('copyingmessage', "%d\n%s\n%s\n%s"  % \
-                (uid, s.getnicename(src), src.getname(), ds))
+                (uid, s.getnicename(src), src.name, ds))
         
     def folderlist(s, list):
-        return ("\f".join(["%s\t%s" % (s.getnicename(x), x.getname()) for x in list]))
+        return ("\f".join(["%s\t%s" % (s.getnicename(x), x.name) for x in list]))
 
     def deletingmessage(s, uid, destlist):
         s.deletingmessages(s, [uid], destlist)
diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py
index 02e4202..29bf670 100644
--- a/offlineimap/ui/UIBase.py
+++ b/offlineimap/ui/UIBase.py
@@ -148,23 +148,23 @@ class UIBase:
         raise NotImplementedError
 
     def folderlist(s, list):
-        return ', '.join(["%s[%s]" % (s.getnicename(x), x.getname()) for x in list])
+        return ', '.join(["%s[%s]" % (s.getnicename(x), x.name) for x in list])
 
     ################################################## WARNINGS
     def msgtoreadonly(s, destfolder, uid, content, flags):
         if not (s.config.has_option('general', 'ignore-readonly') and s.config.getboolean("general", "ignore-readonly")):
             s.warn("Attempted to synchronize message %d to folder %s[%s], but that folder is read-only.  The message will not be copied to that folder." % \
-                   (uid, s.getnicename(destfolder), destfolder.getname()))
+                   (uid, s.getnicename(destfolder), destfolder.name))
 
     def flagstoreadonly(s, destfolder, uidlist, flags):
         if not (s.config.has_option('general', 'ignore-readonly') and s.config.getboolean("general", "ignore-readonly")):
             s.warn("Attempted to modify flags for messages %s in folder %s[%s], but that folder is read-only.  No flags have been modified for that message." % \
-                   (str(uidlist), s.getnicename(destfolder), destfolder.getname()))
+                   (str(uidlist), s.getnicename(destfolder), destfolder.name))
 
     def deletereadonly(s, destfolder, uidlist):
         if not (s.config.has_option('general', 'ignore-readonly') and s.config.getboolean("general", "ignore-readonly")):
             s.warn("Attempted to delete messages %s in folder %s[%s], but that folder is read-only.  No messages have been deleted in that folder." % \
-                   (str(uidlist), s.getnicename(destfolder), destfolder.getname()))
+                   (str(uidlist), s.getnicename(destfolder), destfolder.name))
 
     ################################################## MESSAGES
 
@@ -205,44 +205,44 @@ class UIBase:
     def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
         """Called when a folder sync operation is started."""
         if s.verbose >= 0:
-            s._msg("Syncing %s: %s -> %s" % (srcfolder.getname(),
+            s._msg("Syncing %s: %s -> %s" % (srcfolder.name,
                                              s.getnicename(srcrepos),
                                              s.getnicename(destrepos)))
 
     def skippingfolder(s, folder):
         """Called when a folder sync operation is started."""
         if s.verbose >= 0:
-            s._msg("Skipping %s (not changed)" % folder.getname())
+            s._msg("Skipping %s (not changed)" % folder.name)
 
     def validityproblem(s, folder):
         s.warn("UID validity problem for folder %s (repo %s) (saved %d; got %d); skipping it" % \
-               (folder.getname(), folder.getrepository().getname(),
+               (folder.name, folder.getrepository().getname(),
                 folder.getsaveduidvalidity(), folder.getuidvalidity()))
 
     def loadmessagelist(s, repos, folder):
         if s.verbose > 0:
             s._msg("Loading message list for %s[%s]" % (s.getnicename(repos),
-                                                        folder.getname()))
+                                                        folder.name))
 
     def messagelistloaded(s, repos, folder, count):
         if s.verbose > 0:
             s._msg("Message list for %s[%s] loaded: %d messages" % \
-                   (s.getnicename(repos), folder.getname(), count))
+                   (s.getnicename(repos), folder.name, count))
 
     ############################## Message syncing
 
     def syncingmessages(s, sr, sf, dr, df):
         if s.verbose > 0:
             s._msg("Syncing messages %s[%s] -> %s[%s]" % (s.getnicename(sr),
-                                                          sf.getname(),
+                                                          sf.name,
                                                           s.getnicename(dr),
-                                                          df.getname()))
+                                                          df.name))
 
     def copyingmessage(s, uid, src, destlist):
         if s.verbose >= 0:
             ds = s.folderlist(destlist)
             s._msg("Copy message %d %s[%s] -> %s" % (uid, s.getnicename(src),
-                                                     src.getname(), ds))
+                                                     src.name, ds))
 
     def deletingmessage(s, uid, destlist):
         if s.verbose >= 0:
-- 
1.7.1





More information about the OfflineIMAP-project mailing list