def search_for_count(self, ** args):
if "<STR_LIT>" not in args.keys():<EOL><INDENT>timeout = self.TIMEOUT<EOL><DEDENT>elif args["<STR_LIT>"]:<EOL><INDENT>timeout = args["<STR_LIT>"]<EOL><DEDENT>args["<STR_LIT>"] = timeout / <NUM_LIT:15><EOL>if "<STR_LIT:count>" not in args.keys():<EOL><INDENT>raise EmailException("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>count = int(args["<STR_LIT:count>"])<EOL>del args["<STR_LIT:count>"]<EOL><DEDENT>results = None<EOL>timer = timeout<EOL>count = <NUM_LIT:0><EOL>while count < timer:<EOL><INDENT>try:<EOL><INDENT>results = self.search(** args)<EOL><DEDENT>except EmailException:<EOL><INDENT>if count == <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT><DEDENT>if results and len(results) == count:<EOL><INDENT>return results<EOL><DEDENT>else:<EOL><INDENT>time.sleep(<NUM_LIT:15>)<EOL>count += <NUM_LIT:15><EOL><DEDENT><DEDENT>if count >= timer:<EOL><INDENT>raise EmailException("<STR_LIT>" %<EOL>(args, timeout / <NUM_LIT>))<EOL><DEDENT>
A search that keeps searching up until timeout for a
specific number of matches to a search. If timeout is not
specified we use the default.  If count= is not specified we
will fail. Return values are the same as search(), except for count=0,
where we will return an empty list. Use this if you need to wait for a
number of emails other than 1.

@Params
args - dict of arguments to use in search:
       count - number of emails to search for
       timeout - seconds to try search before timing out
@Returns
List of message numbers matched by search