From af0f602ef1f71e75b7ee8fbb60d4b213ac766b59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 5 Sep 2023 00:44:32 +0200 Subject: [PATCH] Continued: - skip more empty/None strings --- fba/networks/friendica.py | 5 +---- fba/networks/lemmy.py | 19 +++++-------------- fba/networks/mastodon.py | 7 ++----- fba/networks/pleroma.py | 11 ++++------- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/fba/networks/friendica.py b/fba/networks/friendica.py index 317a8ca..1372093 100644 --- a/fba/networks/friendica.py +++ b/fba/networks/friendica.py @@ -85,10 +85,7 @@ def fetch_blocks(domain: str) -> list: reason = tidyup.reason(line.find_all("td")[1].text) logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason) - if blocked is None: - logger.warning("blocked is empty - SKIPPED!") - continue - elif blocked == "": + if blocked is None or blocked == "": logger.warning("line[]='%s' returned empty blocked domain - SKIPPED!", type(line)) continue elif not domain_helper.is_wanted(blocked): diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index e37c2b8..ebbe9a1 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -203,10 +203,7 @@ def fetch_blocks(domain: str) -> list: blocked = tidyup.domain(tag.contents[0]) if tag.contents[0] != "" else None logger.debug("blocked='%s'", blocked) - if blocked is None: - logger.warning("blocked is empty - SKIPPED!") - continue - elif blocked == "": + if blocked is None or blocked == "": logger.warning("blocked='%s' is empty after tidyup.domain() - SKIPPED!", tag.contents[0]) continue elif not domain_helper.is_wanted(blocked): @@ -272,11 +269,8 @@ def fetch_instances(domain: str, origin: str) -> list: peer = tidyup.domain(text) if text != "" else None logger.debug("peer='%s' - AFTER", peer) - if peer is None: - logger.warning("peer is empty - SKIPPED!") - continue - elif peer == "": - logger.warning("peer is an empty string, text='%s' - SKIPPED!", text) + if peer is None or peer == "": + logger.warning("peer='%s' is empty, text='%s' - SKIPPED!", peer, text) continue elif not domain_helper.is_wanted(peer): logger.debug("peer='%s' is not wanted - SKIPPED!", peer) @@ -375,11 +369,8 @@ def parse_script(doc: bs4.BeautifulSoup, only: str = None) -> list: peer = tidyup.domain(row["domain"]) logger.debug("peer='%s' - AFTER!", peer) - if peer is None: - logger.warning("peer is empty - SKIPPED!") - continue - elif peer == "": - logger.warning("peer is an empty string, row[domain]='%s' - SKIPPED!", row["domain"]) + if peer is None or peer == "": + logger.warning("peer='%s' is empty, row[domain]='%s' - SKIPPED!", peer, row["domain"]) continue elif not domain_helper.is_wanted(peer): logger.debug("peer='%s' is not wanted - SKIPPED!", peer) diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index 3b57892..f0de5de 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -124,11 +124,8 @@ def fetch_blocks_from_about(domain: str) -> dict: reason = tidyup.reason(reason) if reason != "" else None logger.debug("domain='%s',reason='%s' - AFTER!", domain, reason) - if domain is None: - logger.warning("domain is empty,line='%s' - SKIPPED!", line) - continue - elif domain == "": - logger.warning("domain is an empty string,line='%s' - SKIPPED!", line) + if domain is None or domain == "": + logger.warning("domain='%s' is empty,line='%s' - SKIPPED!", domain, line) continue logger.debug("Appending domain='%s',hash='%s',reason='%s' to blocklist header_text='%s' ...", domain, hash, reason, blocklist) diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 1a69c23..5f403b9 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -127,11 +127,8 @@ def fetch_blocks(domain: str) -> list: blocked = tidyup.domain(blocked) if blocked != "" else None logger.debug("blocked='%s' - AFTER!", blocked) - if blocked is None: - logger.warning("blocked is empty - SKIPPED!") - continue - elif blocked == "": - logger.warning("blocked is an empty string after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", domain, block_level) + if blocked is None or blocked == "": + logger.warning("blocked='%s' is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", blocked, domain, block_level) continue logger.debug("Invoking utils.deobfuscate(%s, %s) ...", blocked, domain) @@ -158,9 +155,9 @@ def fetch_blocks(domain: str) -> list: for blocked in data["quarantined_instances"]: logger.debug("blocked='%s' - BEFORE!", blocked) blocked = tidyup.domain(blocked) if blocked != "" else None - logger.debug("blocked='%s' - AFTER!", blocked) - if blocked == "": + logger.debug("blocked='%s' - AFTER!", blocked) + if blocked is None or blocked == "": logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue elif not domain_helper.is_wanted(blocked): -- 2.39.5