From: Roland Häder Date: Mon, 13 Jan 2025 00:41:22 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9648c9566fa0cfded86c78f15f99c53310adaab6;p=fba.git Continued: - moved additional if check --- diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py index 8cb79f0..5f8438d 100644 --- a/fba/helpers/processing.py +++ b/fba/helpers/processing.py @@ -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() ...")