1. Kamil Kisiel
  2. hgmbox-imap-pattern

Commits

Kamil Kisiel  committed c2f79a8

Added patch for configuration of IMAP search pattern

  • Participants
  • Parent commits 74e56f9
  • Branches default

Comments (0)

Files changed (2)

File imap_pattern

View file
  • Ignore whitespace
+# HG changeset patch
+# Parent 00648ac467c7dea1b69bcdbf2e0b06ada0f30a55
+Support a per-mailbox pattern for IMAP searches. Not all mailservers support
+the default pattern, or anything other than a blank search pattern.
+
+diff -r 00648ac467c7 mbox.py
+--- a/mbox.py	Sun Aug 15 17:36:37 2010 +0200
++++ b/mbox.py	Mon Dec 27 14:39:36 2010 -0800
+@@ -157,12 +157,13 @@
+         pass
+ 
+ class imapsource(object):
+-    def __init__(self, name, server, user, password, mailbox):
++    def __init__(self, name, server, user, password, mailbox, pattern):
+         self.name = name
+         self.server = server
+         self.user = user
+         self.password = password
+         self.mailbox = mailbox
++        self.pattern = pattern
+ 
+     def _login(self):
+         conn = imaplib.IMAP4_SSL(self.server)
+@@ -180,7 +181,7 @@
+                                % (self.mailbox, self.server, self.user, ok, l)))
+ 
+         # TODO: Use other filter?
+-        type, data = conn.search(None, 'Subject', '[PATCH ')
++        type, data = conn.search(None, 'Subject', self.pattern)
+         for msgnum in data[0].split():
+             ok, resp = conn.fetch(msgnum, '(RFC822)')
+             if ok != 'OK':
+@@ -414,7 +415,7 @@
+ 
+     sources = []
+     types = {
+-        'imap': (imapsource, ('server', 'username', 'password', 'mailbox')),
++        'imap': (imapsource, ('server', 'username', 'password', 'mailbox', 'pattern')),
+         'mbox': (mboxsource, ('path',)),
+         }
+     seen = set()

File series

View file
  • Ignore whitespace
+imap_pattern
 # Placed by Bitbucket