From 66f2f75819a81684481193a78a4d06014565a723 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 21 Jun 2023 03:54:37 +0200 Subject: [PATCH] Continued: - removed duplicate functions - fixed __all__ - removed whitespace - re-added set_detection_mode() --- fba/__init__.py | 1 - fba/fba.py | 1 + fba/helpers/__init__.py | 1 + fba/models/instances.py | 34 ++-------------------------------- fba/networks/friendica.py | 2 +- fba/networks/lemmy.py | 2 +- 6 files changed, 6 insertions(+), 35 deletions(-) diff --git a/fba/__init__.py b/fba/__init__.py index 155bf76..8012885 100644 --- a/fba/__init__.py +++ b/fba/__init__.py @@ -15,7 +15,6 @@ __all__ = [ # Main packages: - 'blacklist', 'boot', 'commands', 'config', diff --git a/fba/fba.py b/fba/fba.py index db37abf..368de88 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -25,6 +25,7 @@ from fba import federation from fba import network from fba.helpers import blacklist +from fba.helpers import cookies from fba.models import instances diff --git a/fba/helpers/__init__.py b/fba/helpers/__init__.py index 91fed03..473eed0 100644 --- a/fba/helpers/__init__.py +++ b/fba/helpers/__init__.py @@ -14,6 +14,7 @@ # along with this program. If not, see . __all__ = [ + 'blacklist', 'cache', 'cookies', 'dicts', diff --git a/fba/models/instances.py b/fba/models/instances.py index 836a1ef..83402e7 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -383,7 +383,7 @@ def set_total_peers(domain: str, peers: list): _set_data("total_peers", domain, len(peers)) # DEBUG: print("DEBUG: EXIT!") -def set_nodeinfo_url(domain: str, url: list): +def set_nodeinfo_url(domain: str, url: str): # DEBUG: print(f"DEBUG: domain='{domain}',url='{url}' - CALLED!") if not isinstance(domain, str): raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") @@ -398,37 +398,7 @@ def set_nodeinfo_url(domain: str, url: list): _set_data("nodeinfo_url", domain, url) # DEBUG: print("DEBUG: EXIT!") -def set_detection_mode(domain: str, url: list): - # DEBUG: print(f"DEBUG: domain='{domain}',url='{url}' - CALLED!") - if not isinstance(domain, str): - raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") - elif domain == "": - raise ValueError("Parameter 'domain' is empty") - elif not isinstance(url, str): - raise ValueError("Parameter url[]='{type(url)}' is not 'list'") - elif url == "": - raise ValueError("Parameter 'url' is empty") - - # Set timestamp - _set_data("detection_mode", domain, url) - # DEBUG: print("DEBUG: EXIT!") - -def set_detection_mode(domain: str, url: list): - # DEBUG: print(f"DEBUG: domain='{domain}',url='{url}' - CALLED!") - if not isinstance(domain, str): - raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") - elif domain == "": - raise ValueError("Parameter 'domain' is empty") - elif not isinstance(url, str): - raise ValueError("Parameter url[]='{type(url)}' is not 'list'") - elif url == "": - raise ValueError("Parameter 'url' is empty") - - # Set timestamp - _set_data("detection_mode", domain, url) - # DEBUG: print("DEBUG: EXIT!") - -def set_detection_mode(domain: str, mode: list): +def set_detection_mode(domain: str, mode: str): # DEBUG: print(f"DEBUG: domain='{domain}',mode='{mode}' - CALLED!") if not isinstance(domain, str): raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") diff --git a/fba/networks/friendica.py b/fba/networks/friendica.py index 393f659..e6138c7 100644 --- a/fba/networks/friendica.py +++ b/fba/networks/friendica.py @@ -87,7 +87,7 @@ def fetch_blocks(domain: str) -> dict: continue blocked.append({ - "domain": tidyup.domain(domaih), + "domain": tidyup.domain(blocked), "reason": tidyup.reason(line.find_all("td")[1].text) }) # DEBUG: print("DEBUG: Next!") diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 541dd55..e8ca1e1 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -163,7 +163,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str): for header in headers: # DEBUG: print(f"DEBUG: header[]={type(header)}") content = header.contents[0] - + # DEBUG: print(f"DEBUG: content='{content}'") if content in translations: # DEBUG: print("DEBUG: Found header with blocked instances - BREAK!") -- 2.39.5