Returns a list of indices for the given query, latest-first. The search field can be FROM, DATE or SUBJECT.
(self, q, field=FROM, cached=False)
| 212 | return len(self) |
| 213 | |
| 214 | def search(self, q, field=FROM, cached=False): |
| 215 | """ Returns a list of indices for the given query, latest-first. |
| 216 | The search field can be FROM, DATE or SUBJECT. |
| 217 | """ |
| 218 | id = "mail-%s-%s-%s-%s" % (self.parent._id, self.name, q, field) |
| 219 | if cached and id in cache: |
| 220 | status, response = "OK", [cache[id]] |
| 221 | else: |
| 222 | status, response = self.parent.imap4.select(self._name, readonly=1) |
| 223 | status, response = self.parent.imap4.search(None, field.upper(), q) |
| 224 | if cached: |
| 225 | cache[id] = response[0] |
| 226 | return sorted([int(i)-1 for i in response[0].split()], reverse=True) |
| 227 | |
| 228 | def read(self, i, attachments=False, cached=True): |
| 229 | return self.__getitem__(i, attachments, cached) |
no test coverage detected