From: Olivier Matz Date: Mon, 28 Nov 2016 10:07:57 +0000 (+0100) Subject: fix not ? X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=05ae5213eef8e644464d9376c6957ef1429936ef;p=imapami.git fix not ? --- diff --git a/imapami/conditions.py b/imapami/conditions.py index 600a2c6..6b45510 100644 --- a/imapami/conditions.py +++ b/imapami/conditions.py @@ -102,9 +102,9 @@ class ImapamiCond(object): :arg ImapamiMail mail: The mail data :returns: - True if the condition matches, else False. + None if nothing to check, True if the condition matches, else False. """ - return True + return None def get_criteria(self): """ @@ -133,7 +133,10 @@ class ImapamiCondNot(ImapamiCond): self.cond = cond def check(self, ami, mail): - return not self.cond.check(ami, mail) + ret = self.cond.check(ami, mail) + if ret is None: + return None + return not ret register(ImapamiCondNot) class ImapamiCondUnseen(ImapamiCond): @@ -642,10 +645,14 @@ class ImapamiCondAnd(ImapamiCond): self.cond_list = cond_list def check(self, ami, mail): + ret = None for c in self.cond_list: - if c.check(ami, mail) == False: + val = c.check(ami, mail) + if val is False: return False - return True + if val is True: + ret = True + return ret register(ImapamiCondAnd) class ImapamiCondOr(ImapamiCond): @@ -683,10 +690,14 @@ class ImapamiCondOr(ImapamiCond): self.cond_list = cond_list def check(self, ami, mail): + ret = None for c in self.cond_list: - if c.check(ami, mail) == True: + val = c.check(ami, mail) + if val is True: return True - return False + if val is False: + ret = False + return ret register(ImapamiCondOr) class ImapamiCondEq(ImapamiCond): diff --git a/imapami/rules.py b/imapami/rules.py index 3adff91..d5b1f9f 100644 --- a/imapami/rules.py +++ b/imapami/rules.py @@ -246,7 +246,7 @@ class ImapamiRule(object): mail_data['internal_date']) mail = imapami.mail.ImapamiMail(**mail_data) - if self.condition.check(ami, mail) == True: + if self.condition.check(ami, mail) in [None, True]: ami.logger.debug("item %s matches conditions", item) success = self.match_action.process(ami, mail) else: