]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 13 Jan 2025 00:41:22 +0000 (01:41 +0100)
committerRoland Häder <roland@mxchange.org>
Mon, 13 Jan 2025 00:41:22 +0000 (01:41 +0100)
- moved additional if check

fba/helpers/processing.py

index 8cb79f01a3a68573ef67042a3aadced52a36a1f2..5f8438d86d0a09ab8bd3d3a16a9f23e0a297a384 100644 (file)
@@ -170,15 +170,17 @@ def csv_block(blocker: str, url: str, command: str) -> None:
     logger.info("Checking %d CSV lines ...", len(rows))
     for row in rows:
         logger.debug("row[%s]='%s'", type(row), row)
+
+        # Init variables
         domain = severity = reason = None
         reject_media = reject_reports = False
 
-        if "#domain" in row:
-            domain = tidyup.domain(row["#domain"]) if row["#domain"] not in [None, ""] else None
-        elif "domain" in row:
-            domain = tidyup.domain(row["domain"]) if row["domain"] not in [None, ""] else None
-        elif "Domain" in row:
-            domain = tidyup.domain(row["Domain"]) if row["Domain"] not in [None, ""] else None
+        if "#domain" in row and row["#domain"] not in [None, ""]:
+            domain = tidyup.domain(row["#domain"])
+        elif "domain" in row and row["domain"] not in [None, ""]:
+            domain = tidyup.domain(row["domain"])
+        elif "Domain" in row and row["Domain"] not in [None, ""]:
+            domain = tidyup.domain(row["Domain"])
         else:
             logger.warning("row='%s' does not contain domain column - SKIPPED!", row)
             continue
@@ -191,12 +193,12 @@ def csv_block(blocker: str, url: str, command: str) -> None:
             logger.debug("row='%s' does not contain severity column, setting 'reject'", row)
             severity = "rejected"
 
-        if "reason" in row:
-            reason = tidyup.reason(row["reason"]) if row["reason"] not in [None, ""] else None
-        elif "comment" in row:
-            reason = tidyup.reason(row["comment"]) if row["comment"] not in [None, ""] else None
-        elif "Comment" in row:
-            reason = tidyup.reason(row["Comment"]) if row["Comment"] not in [None, ""] else None
+        if "reason" in row and row["reason"] not in [None, ""]:
+            reason = tidyup.reason(row["reason"])
+        elif "comment" in row and row["comment"] not in [None, ""]:
+            reason = tidyup.reason(row["comment"])
+        elif "Comment" in row and row["Comment"] not in [None, ""]:
+            reason = tidyup.reason(row["Comment"])
         else:
             logger.debug("row='%s' has no reason/comment key provided", row)
 
@@ -253,8 +255,10 @@ def csv_block(blocker: str, url: str, command: str) -> None:
 
         logger.debug("reject_media='%s',reject_reports='%s'", reject_media, reject_reports)
         if reject_media:
+            logger.debug("blocker='%s',domain='%s',reject_media=True", blocker, domain)
             block(blocker, domain, None, "reject_media")
         if reject_reports:
+            logger.debug("blocker='%s',domain='%s',reject_reports=True", blocker, domain)
             block(blocker, domain, None, "reject_reports")
 
         logger.debug("Invoking commit() ...")