[PATCH 2/3] folder/Base.py: Implement uidexists helper function

Sebastian Spaeth Sebastian at SSpaeth.de
Thu Jan 20 12:16:52 GMT 2011


Rather than calling

  if uid in Folder.getmessagelist.keys():

all the time, lets us use the shorter and more intuitive

 if Folder.uidexists(uid):

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
 offlineimap/folder/Base.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 953ba70..f4c80a0 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -119,6 +119,14 @@ class BaseFolder:
     def getuidvalidity(self):
         raise NotImplementedException
 
+    def uidexists(self, uid):
+        """Tests if a message UID exists in the folder
+
+        You must call cachemessagelist() before calling this function!
+        :param uid: a string representing a message uid.
+        :returns: True if yes, False if no."""
+        return uid in self.getmessagelist()
+
     def cachemessagelist(self):
         """Reads the message list from disk or network and stores it in
         memory for later use.  This list will not be re-read from disk or
-- 
1.7.1





More information about the OfflineIMAP-project mailing list