MCPcopy Index your code
hub / github.com/clips/pattern / search

Method search

pattern/web/imap/__init__.py:214–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 3

email_addressMethod · 0.45
encode_basestringFunction · 0.45

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected