You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/10/16 23:55:01 UTC

[incubator-ponymail-foal] 01/02: simplify logic

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit d024a764479b8f7a591dbce096727d7c8ccc7971
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Oct 17 01:51:55 2021 +0200

    simplify logic
---
 server/plugins/defuzzer.py | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/server/plugins/defuzzer.py b/server/plugins/defuzzer.py
index 09f3981..ce527b5 100644
--- a/server/plugins/defuzzer.py
+++ b/server/plugins/defuzzer.py
@@ -161,29 +161,29 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
                 )
             xmust = {"bool": {"minimum_should_match": len(should), "should": xshould}}
             must.append(xmust)
-        if shouldnot:
-            for x in shouldnot:
-                must_not.append(
-                    {
-                        "match": {
-                            "subject": x,
-                        }
+
+        for x in shouldnot:
+            must_not.append(
+                {
+                    "match": {
+                        "subject": x,
                     }
-                )
-                must_not.append(
-                    {
-                        "match": {
-                            "from": x,
-                        }
+                }
+            )
+            must_not.append(
+                {
+                    "match": {
+                        "from": x,
                     }
-                )
-                must_not.append(
-                    {
-                        "match": {
-                            "body": x,
-                        }
+                }
+            )
+            must_not.append(
+                {
+                    "match": {
+                        "body": x,
                     }
-                )
+                }
+            )
 
     # Header parameters
     for header in ["from", "subject", "body", "to"]:
@@ -194,7 +194,7 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
 
     thebool = {"must": must}
 
-    if len(must_not) > 0:
+    if must_not:
         thebool["must_not"] = must_not
 
     return thebool