我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用imaplib.ParseFlags()。
def _clean_message_data(fetch_data): """ :param fetch_data: Message object model :returns [message_data: bytes, uid_data: bytes, flag_data: list] *Elements may contain byte strings in any order, like: b'4517 (FLAGS (\\Recent NonJunk))' """ message_data = b'' uid_data = b'' flag_data = [] for fetch_item in fetch_data: # flags if type(fetch_item) is bytes and imaplib.ParseFlags(fetch_item): flag_data.extend(imaplib.ParseFlags(fetch_item)) # data, uid if type(fetch_item) is tuple: uid_data = fetch_item[0] message_data = fetch_item[1] return message_data, uid_data, flag_data
def store(self, *args): """ implements some flag commands args: ("<id>", "<+|->FLAGS", "(\\Flag1 \\Flag2 ... \\Flagn)") """ message = self.spam[self._mailbox][int(args[0] - 1)] old_flags = ParseFlags(message["flags"]) flags = ParseFlags("FLAGS" + args[2]) if args[1].strip().startswith("+"): message["flags"] = "FLAGS (%s)" % " ".join(set(flags + old_flags)) elif args[1].strip().startswith("-"): message["flags"] = "FLAGS (%s)" % " ".join([flag for flag in old_flags if not flag in flags])
def parse_flags(self, headers): return list(ParseFlags(headers)) # flags = re.search(r'FLAGS \(([^\)]*)\)', headers).groups(1)[0].split(' ')