From aa6a95081bb9fd510eb1b838c7c929fbae92c300 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Jul 2023 15:26:12 +0200 Subject: [PATCH] Continued: - wording fixed: "Parameter foo[]='%s' is not type of '%'" --- fba/commands.py | 2 +- fba/csrf.py | 2 +- fba/helpers/cache.py | 10 +++++----- fba/helpers/config.py | 2 +- fba/helpers/cookies.py | 2 +- fba/helpers/dicts.py | 6 +++--- fba/helpers/domain.py | 4 ++-- fba/helpers/tidyup.py | 4 ++-- fba/helpers/version.py | 8 ++++---- fba/http/federation.py | 20 ++++++++++---------- fba/http/network.py | 24 ++++++++++++------------ fba/models/blocks.py | 14 +++++++------- fba/models/instances.py | 28 ++++++++++++++-------------- fba/networks/lemmy.py | 2 +- fba/networks/mastodon.py | 2 +- fba/networks/misskey.py | 2 +- fba/networks/pleroma.py | 2 +- fba/utils.py | 14 +++++++------- 18 files changed, 74 insertions(+), 74 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 89a3757..95484ae 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1218,7 +1218,7 @@ def fetch_joinfediverse(args: argparse.Namespace) -> int: logger.debug("text[]='%s'", type(text)) if not isinstance(text, str): - logger.debug("text[]='%s' is not 'str' - SKIPPED!", type(text)) + logger.debug("text[]='%s' is not of type 'str' - SKIPPED!", type(text)) continue elif validators.domain(text.strip()): logger.debug("text='%s' is a domain - SKIPPED!", text.strip()) diff --git a/fba/csrf.py b/fba/csrf.py index c523159..f529af3 100644 --- a/fba/csrf.py +++ b/fba/csrf.py @@ -36,7 +36,7 @@ def determine(domain: str, headers: dict) -> dict: domain_helper.raise_on(domain) if not isinstance(headers, dict): - raise ValueError(f"Parameter headers[]='{type(headers)}' is not 'dict'") + raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'") # Default headers with no CSRF reqheaders = headers diff --git a/fba/helpers/cache.py b/fba/helpers/cache.py index 7a20a41..8800bca 100644 --- a/fba/helpers/cache.py +++ b/fba/helpers/cache.py @@ -31,7 +31,7 @@ def key_exists(key: str) -> bool: def set_all(key: str, rows: list, value: any): logger.debug("key='%s',rows()=%d,value[]='%s' - CALLED!", key, len(rows), type(value)) if not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif not key_exists(key): logger.debug("Cache for key='%s' not initialized.", key) _cache[key] = dict() @@ -49,9 +49,9 @@ def set_all(key: str, rows: list, value: any): def set_sub_key(key: str, sub: str, value: any): logger.debug("key='%s',sub='%s',value[]='%s' - CALLED!", key, sub, type(value)) if not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif not isinstance(sub, str): - raise ValueError(f"Parameter sub[]='{type(sub)}' is not 'str'") + raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'") elif not key_exists(key): raise Exception(f"Cache for key='{key}' is not initialized, but function invoked") @@ -63,9 +63,9 @@ def set_sub_key(key: str, sub: str, value: any): def sub_key_exists(key: str, sub: str) -> bool: logger.debug("key='%s',sub='%s' - CALLED!", key, sub) if not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif not isinstance(sub, str): - raise ValueError(f"Parameter sub[]='{type(sub)}' is not 'str'") + raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'") elif not key_exists(key): raise Exception(f"Cache for key='{key}' is not initialized, but function invoked") diff --git a/fba/helpers/config.py b/fba/helpers/config.py index b684f90..8fe1bd6 100644 --- a/fba/helpers/config.py +++ b/fba/helpers/config.py @@ -27,7 +27,7 @@ with open("config.json") as f: def get(key: str) -> any: logger.debug("key[%s]='%s' - CALLED!", type(key), key) if not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif key == "": raise ValueError("Parameter 'key' is empty") elif not key in _config: diff --git a/fba/helpers/cookies.py b/fba/helpers/cookies.py index b963a13..eebc7b8 100644 --- a/fba/helpers/cookies.py +++ b/fba/helpers/cookies.py @@ -28,7 +28,7 @@ def store (domain: str, cookies: dict): logger.debug("domain='%s',cookies()=%d - CALLED!", domain, len(cookies)) domain_helper.raise_on(domain) if not isinstance(cookies, dict): - raise ValueError(f"Parameter cookies[]='{type(cookies)}' is not 'dict'") + raise ValueError(f"Parameter cookies[]='{type(cookies)}' is not of type 'dict'") _cookies[domain] = cookies diff --git a/fba/helpers/dicts.py b/fba/helpers/dicts.py index 3f8a7e6..b3f2632 100644 --- a/fba/helpers/dicts.py +++ b/fba/helpers/dicts.py @@ -21,9 +21,9 @@ logger = logging.getLogger(__name__) def has_key(lists: list, key: str, value: any) -> bool: logger.debug("lists()=%d,key='%s',value[]='%s' - CALLED!", len(lists), key, type(value)) if not isinstance(lists, list): - raise ValueError(f"Parameter lists[]='{type(lists)}' is not 'list'") + raise ValueError(f"Parameter lists[]='{type(lists)}' is not of type 'list'") elif not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif key == "": raise ValueError("Parameter 'key' is empty") @@ -32,7 +32,7 @@ def has_key(lists: list, key: str, value: any) -> bool: for row in lists: logger.debug("row[%s]='%s", type(row), row) if not isinstance(row, dict): - raise ValueError(f"row[]='{type(row)}' is not 'dict'") + raise ValueError(f"row[]='{type(row)}' is not of type 'dict'") elif not key in row: raise KeyError(f"Cannot find key='{key}'") elif row[key] == value: diff --git a/fba/helpers/domain.py b/fba/helpers/domain.py index 4e7dc38..5328e3f 100644 --- a/fba/helpers/domain.py +++ b/fba/helpers/domain.py @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) def raise_on(domain: str): logger.debug("domain='%s' - CALLED!", domain) if not isinstance(domain, str): - raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") + raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'") elif domain == "": raise ValueError("Parameter 'domain' is empty") elif domain.lower() != domain: @@ -47,7 +47,7 @@ def is_in_url(domain: str, url: str) -> bool: raise_on(domain) if not isinstance(url, str): - raise ValueError(f"Parameter url[]='%s' is not 'str'", type(url)) + raise ValueError(f"Parameter url[]='%s' is not of type 'str'", type(url)) elif url == "": raise ValueError("Parameter 'url' is empty") diff --git a/fba/helpers/tidyup.py b/fba/helpers/tidyup.py index ef027af..3f6fa35 100644 --- a/fba/helpers/tidyup.py +++ b/fba/helpers/tidyup.py @@ -22,7 +22,7 @@ logger = logging.getLogger(__name__) def reason(string: str) -> str: logger.debug("string='%s' - CALLED!", string) if not isinstance(string, str): - raise ValueError(f"Parameter string[]='{type(string)}' is not 'str'") + raise ValueError(f"Parameter string[]='{type(string)}' is not of type 'str'") # Strip string string = string.strip() @@ -33,7 +33,7 @@ def reason(string: str) -> str: def domain(string: str) -> str: logger.debug("string='%s' - CALLED!", string) if not isinstance(string, str): - raise ValueError(f"Parameter string[]='{type(string)}' is not 'str'") + raise ValueError(f"Parameter string[]='{type(string)}' is not of type 'str'") # All lower-case and strip spaces out + last dot string = string.lower().strip().rstrip(".") diff --git a/fba/helpers/version.py b/fba/helpers/version.py index aa0c54f..19ad520 100644 --- a/fba/helpers/version.py +++ b/fba/helpers/version.py @@ -88,7 +88,7 @@ def remove(software: str) -> str: def strip_powered_by(software: str) -> str: logger.debug("software='%s' - CALLED!", software) if not isinstance(software, str): - raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") elif "powered by" not in software: @@ -109,7 +109,7 @@ def strip_powered_by(software: str) -> str: def strip_hosted_on(software: str) -> str: logger.debug("software='%s' - CALLED!", software) if not isinstance(software, str): - raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") elif "hosted on" not in software: @@ -130,11 +130,11 @@ def strip_hosted_on(software: str) -> str: def strip_until(software: str, until: str) -> str: logger.debug("software='%s',until='%s' - CALLED!", software, until) if not isinstance(software, str): - raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") elif not isinstance(until, str): - raise ValueError(f"Parameter until[]='{type(until)}' is not 'str'") + raise ValueError(f"Parameter until[]='{type(until)}' is not of type 'str'") elif until == "": raise ValueError("Parameter 'until' is empty") elif not until in software: diff --git a/fba/http/federation.py b/fba/http/federation.py index f8b0450..c7c2fd8 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -46,9 +46,9 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: domain_helper.raise_on(domain) if not isinstance(origin, str) and origin is not None: - raise ValueError(f"Parameter origin[]='{type(origin)}' is not 'str'") + raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'") elif not isinstance(command, str): - raise ValueError(f"Parameter command[]='{type(command)}' is not 'str'") + raise ValueError(f"Parameter command[]='{type(command)}' is not of type 'str'") elif command == "": raise ValueError("Parameter 'command' is empty") elif software is None: @@ -61,7 +61,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("Determined software='%s' for domain='%s'", software, domain) elif not isinstance(software, str): - raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") logger.debug("Checking if domain='%s' is registered ...", domain) if not instances.is_registered(domain): @@ -139,7 +139,7 @@ def fetch_peers(domain: str, software: str, origin: str) -> list: domain_helper.raise_on(domain) if not isinstance(software, str) and software is not None: - raise ValueError(f"software[]='{type(software)}' is not 'str'") + raise ValueError(f"software[]='{type(software)}' is not of type 'str'") if software == "misskey": logger.debug("Invoking misskey.fetch_peers(%s) ...", domain) @@ -193,7 +193,7 @@ def fetch_peers(domain: str, software: str, origin: str) -> list: break if not isinstance(peers, list): - logger.warning("peers[]='%s' is not 'list', maybe bad API response?", type(peers)) + logger.warning("peers[]='%s' is not of type 'list', maybe bad API response?", type(peers)) peers = list() logger.debug("Invoking instances.set_total_peers(%s,%d) ...", domain, len(peers)) @@ -207,7 +207,7 @@ def fetch_nodeinfo(domain: str, path: str = None) -> dict: domain_helper.raise_on(domain) if not isinstance(path, str) and path is not None: - raise ValueError(f"Parameter path[]='{type(path)}' is not 'str'") + raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") logger.debug("Fetching nodeinfo from domain='%s' ...", domain) nodeinfo = fetch_wellknown_nodeinfo(domain) @@ -334,7 +334,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict: for link in nodeinfo["links"]: logger.debug("link[%s]='%s'", type(link), link) if not isinstance(link, dict) or not "rel" in link: - logger.debug("link[]='%s' is not 'dict' or no element 'rel' found - SKIPPED!", type(link)) + logger.debug("link[]='%s' is not of type 'dict' or no element 'rel' found - SKIPPED!", type(link)) continue elif link["rel"] != niid: logger.debug("link[re]='%s' does not matched niid='%s' - SKIPPED!", link["rel"], niid) @@ -396,7 +396,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: domain_helper.raise_on(domain) if not isinstance(path, str): - raise ValueError(f"path[]='{type(path)}' is not 'str'") + raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") @@ -485,7 +485,7 @@ def determine_software(domain: str, path: str = None) -> str: domain_helper.raise_on(domain) if not isinstance(path, str) and path is not None: - raise ValueError(f"Parameter path[]='{type(path)}' is not 'str'") + raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") logger.debug("Determining software for domain='%s',path='%s'", domain, path) software = None @@ -616,7 +616,7 @@ def find_domains(tag: bs4.element.Tag) -> list: def add_peers(rows: dict) -> list: logger.debug("rows[]='%s' - CALLED!", type(rows)) if not isinstance(rows, dict): - raise ValueError(f"Parameter rows[]='{type(rows)}' is not 'dict'") + raise ValueError(f"Parameter rows[]='{type(rows)}' is not of type 'dict'") peers = list() for key in ["linked", "allowed", "blocked"]: diff --git a/fba/http/network.py b/fba/http/network.py index 58d44af..5db3a98 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -61,13 +61,13 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = dict() domain_helper.raise_on(domain) if not isinstance(path, str): - raise ValueError(f"path[]='{type(path)}' is not 'str'") + raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") elif not isinstance(data, str): - raise ValueError(f"data[]='{type(data)}' is not 'str'") + raise ValueError(f"data[]='{type(data)}' is not of type 'str'") elif not isinstance(headers, dict): - raise ValueError(f"headers[]='{type(headers)}' is not 'list'") + raise ValueError(f"headers[]='{type(headers)}' is not of type 'list'") json_reply = { "status_code": 200, @@ -109,11 +109,11 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = dict() def fetch_api_url(url: str, timeout: tuple) -> dict: logger.debug("url='%s',timeout()=%d - CALLED!", url, len(timeout)) if not isinstance(url, str): - raise ValueError(f"Parameter url[]='{type(url)}' is not 'str'") + raise ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'") elif url == "": raise ValueError("Parameter 'url' is empty") elif not isinstance(timeout, tuple): - raise ValueError(f"timeout[]='{type(timeout)}' is not 'tuple'") + raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'") json_reply = { "status_code": 200, @@ -148,13 +148,13 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict: domain_helper.raise_on(domain) if not isinstance(path, str): - raise ValueError(f"path[]='{type(path)}' is not 'str'") + raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") elif not isinstance(headers, dict): - raise ValueError(f"headers[]='{type(headers)}' is not 'list'") + raise ValueError(f"headers[]='{type(headers)}' is not of type 'list'") elif not isinstance(timeout, tuple): - raise ValueError(f"timeout[]='{type(timeout)}' is not 'tuple'") + raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'") json_reply = { "status_code": 200, @@ -197,7 +197,7 @@ def send_bot_post(domain: str, blocklist: list): domain_helper.raise_on(domain) if not isinstance(blocklist, list): - raise ValueError(f"Parameter blocklist[]='{type(blocklist)}' is not 'list'") + raise ValueError(f"Parameter blocklist[]='{type(blocklist)}' is not of type 'list'") elif len(blocklist) == 0: raise ValueError("Parameter 'blocklist' is empty") @@ -243,13 +243,13 @@ def fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow_ domain_helper.raise_on(domain) if not isinstance(path, str): - raise ValueError(f"Parameter path[]='{type(path)}' is not 'str'") + raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") elif not isinstance(headers, dict): - raise ValueError(f"headers[]='{type(headers)}' is not 'dict'") + raise ValueError(f"headers[]='{type(headers)}' is not of type 'dict'") elif not isinstance(timeout, tuple): - raise ValueError(f"timeout[]='{type(timeout)}' is not 'tuple'") + raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'") try: logger.debug("Sending GET request to '%s%s' ...", domain, path) diff --git a/fba/models/blocks.py b/fba/models/blocks.py index a439084..d7e7121 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -30,21 +30,21 @@ logger = logging.getLogger(__name__) def update_reason(reason: str, blocker: str, blocked: str, block_level: str): logger.debug("reason='%s',blocker='%s',blocked='%s',block_level='%s' - CALLED!", reason, blocker, blocked, block_level) if not isinstance(reason, str) and reason is not None: - raise ValueError(f"Parameter reason[]='{type(reason)}' is not 'str'") + raise ValueError(f"Parameter reason[]='{type(reason)}' is not of type 'str'") elif not isinstance(blocker, str): - raise ValueError(f"Parameter blocker[]='{type(blocker)}' is not 'str'") + raise ValueError(f"Parameter blocker[]='{type(blocker)}' is not of type 'str'") elif blocker == "": raise ValueError("Parameter 'blocker' is empty") elif blocker.lower() != blocker: raise ValueError(f"Parameter blocker='{blocker}' must be all lower-case") elif not isinstance(blocked, str): - raise ValueError(f"Parameter blocked[]='{type(blocked)}' is not 'str'") + raise ValueError(f"Parameter blocked[]='{type(blocked)}' is not of type 'str'") elif blocked == "": raise ValueError("Parameter 'blocked' is empty") elif blocked.lower() != blocked: raise ValueError(f"Parameter blocked='{blocked}' must be all lower-case") elif not isinstance(block_level, str): - raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'") + raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'") elif block_level == "": raise ValueError("Parameter 'block_level' is empty") elif block_level in ["accept", "suspend", "silence", "nsfw"]: @@ -66,19 +66,19 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str): def update_last_seen(blocker: str, blocked: str, block_level: str): logger.debug("blocker='%s',blocked='%s',block_level='%s' - CALLED!", blocker, blocked, block_level) if not isinstance(blocker, str): - raise ValueError(f"Parameter blocker[]='{type(blocker)}' is not 'str'") + raise ValueError(f"Parameter blocker[]='{type(blocker)}' is not of type 'str'") elif blocker == "": raise ValueError("Parameter 'blocker' is empty") elif blocker.lower() != blocker: raise ValueError(f"Parameter blocker='{blocker}' must be all lower-case") elif not isinstance(blocked, str): - raise ValueError(f"Parameter blocked[]='{type(blocked)}' is not 'str'") + raise ValueError(f"Parameter blocked[]='{type(blocked)}' is not of type 'str'") elif blocked == "": raise ValueError("Parameter 'blocked' is empty") elif blocked.lower() != blocked: raise ValueError(f"Parameter blocked='{blocked}' must be all lower-case") elif not isinstance(block_level, str): - raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'") + raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'") elif block_level == "": raise ValueError("Parameter 'block_level' is empty") elif block_level in ["accept", "suspend", "silence", "nsfw"]: diff --git a/fba/models/instances.py b/fba/models/instances.py index c1ca5ea..bb8d1fe 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -73,7 +73,7 @@ def _set_data(key: str, domain: str, value: any): logger.debug("key='%s',domain='%s',value[]='%s' - CALLED!", key, domain, type(value)) domain_helper.raise_on(domain) if not isinstance(key, str): - raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'") + raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'") elif key == "": raise ValueError("Parameter 'key' is empty") elif not key in _pending: @@ -155,19 +155,19 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str domain_helper.raise_on(domain) if not isinstance(origin, str) and origin is not None: - raise ValueError(f"origin[]='{type(origin)}' is not 'str'") + raise ValueError(f"origin[]='{type(origin)}' is not of type 'str'") elif origin == "": raise ValueError("Parameter 'origin' is empty") elif not isinstance(command, str): - raise ValueError(f"command[]='{type(command)}' is not 'str'") + raise ValueError(f"command[]='{type(command)}' is not of type 'str'") elif command == "": raise ValueError("Parameter 'command' is empty") elif not isinstance(path, str) and path is not None: - raise ValueError(f"path[]='{type(path)}' is not 'str'") + raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") elif not isinstance(software, str) and software is not None: - raise ValueError(f"software[]='{type(software)}' is not 'str'") + raise ValueError(f"software[]='{type(software)}' is not of type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") elif origin is not None and not validators.domain(origin.split("/")[0]): @@ -292,7 +292,7 @@ def is_recent(domain: str, column: str = "last_instance_fetch") -> bool: domain_helper.raise_on(domain) if not isinstance(column, str): - raise ValueError(f"Parameter column[]='{type(column)}' is not 'str'") + raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'") elif column not in ["last_instance_fetch", "last_blocked"]: raise ValueError(f"Parameter column='{column}' is not expected") elif not is_registered(domain): @@ -316,13 +316,13 @@ def deobfuscate(char: str, domain: str, blocked_hash: str = None) -> tuple: domain_helper.raise_on(domain) if not isinstance(char, str): - raise ValueError(f"Parameter char[]='{type(char)}' is not 'str'") + raise ValueError(f"Parameter char[]='{type(char)}' is not of type 'str'") elif char == "": raise ValueError("Parameter 'char' is empty") elif not char in domain: raise ValueError(f"char='{char}' not found in domain='{domain}' but function invoked") elif not isinstance(blocked_hash, str) and blocked_hash is not None: - raise ValueError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not 'str'") + raise ValueError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not of type 'str'") # Init row row = None @@ -383,7 +383,7 @@ def set_total_peers(domain: str, peers: list): domain_helper.raise_on(domain) if not isinstance(peers, list): - raise ValueError(f"Parameter peers[]='{type(peers)}' is not 'list'") + raise ValueError(f"Parameter peers[]='{type(peers)}' is not of type 'list'") # Set timestamp _set_data("total_peers", domain, len(peers)) @@ -394,7 +394,7 @@ def set_total_blocks(domain: str, blocks: list): domain_helper.raise_on(domain) if not isinstance(blocks, list): - raise ValueError(f"Parameter blocks[]='{type(blocks)}' is not 'list'") + raise ValueError(f"Parameter blocks[]='{type(blocks)}' is not of type 'list'") # Set timestamp _set_data("total_blocks", domain, len(blocks)) @@ -405,7 +405,7 @@ def set_nodeinfo_url(domain: str, url: str): domain_helper.raise_on(domain) if not isinstance(url, str) and url is not None: - raise ValueError(f"Parameter url[]='{type(url)}' is not 'str'") + raise ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'") elif url == "": raise ValueError("Parameter 'url' is empty") @@ -418,7 +418,7 @@ def set_detection_mode(domain: str, mode: str): domain_helper.raise_on(domain) if not isinstance(mode, str) and mode is not None: - raise ValueError(f"Parameter mode[]='{type(mode)}' is not 'str'") + raise ValueError(f"Parameter mode[]='{type(mode)}' is not of type 'str'") elif mode == "": raise ValueError("Parameter 'mode' is empty") @@ -431,7 +431,7 @@ def set_has_obfuscation(domain: str, status: bool): domain_helper.raise_on(domain) if not isinstance(status, bool): - raise ValueError(f"Parameter status[]='{type(status)}' is not 'bool'") + raise ValueError(f"Parameter status[]='{type(status)}' is not of type 'bool'") # Set timestamp _set_data("has_obfuscation", domain, status) @@ -442,7 +442,7 @@ def set_software(domain: str, software: str): domain_helper.raise_on(domain) if not isinstance(software, str) and software is not None: - raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 88e18e0..ad0385e 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -87,7 +87,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: domain_helper.raise_on(domain) if not isinstance(nodeinfo_url, str): - raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not 'str'") + raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not of type 'str'") elif nodeinfo_url == "": raise ValueError("Parameter 'nodeinfo_url' is empty") diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index 0dc4dfa..cc1f463 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -131,7 +131,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: domain_helper.raise_on(domain) if not isinstance(nodeinfo_url, str): - raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not 'str'") + raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not of type 'str'") elif nodeinfo_url == "": raise ValueError("Parameter 'nodeinfo_url' is empty") diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index 0614a57..1f6e42d 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -102,7 +102,7 @@ def fetch_peers(domain: str) -> list: logger.warning("row()=%d does not contain key 'host': row='%s',domain='%s' - SKIPPED!", len(row), row, domain) continue elif not isinstance(row["host"], str): - logger.warning("row[host][]='%s' is not 'str' - SKIPPED!", type(row['host'])) + logger.warning("row[host][]='%s' is not of type 'str' - SKIPPED!", type(row['host'])) continue elif not utils.is_domain_wanted(row["host"]): logger.debug("row[host]='%s' is not wanted, domain='%s' - SKIPPED!", row['host'], domain) diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index ebb7a6e..abbf88d 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -54,7 +54,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: domain_helper.raise_on(domain) if not isinstance(nodeinfo_url, str): - raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not 'str'") + raise ValueError(f"Parameter nodeinfo_url[]='{type(nodeinfo_url)}' is not of type 'str'") elif nodeinfo_url == "": raise ValueError("Parameter 'nodeinfo_url' is empty") diff --git a/fba/utils.py b/fba/utils.py index 1775353..30f3a1c 100644 --- a/fba/utils.py +++ b/fba/utils.py @@ -50,13 +50,13 @@ def get_hash(domain: str) -> str: def fetch_url(url: str, headers: dict, timeout: tuple) -> requests.models.Response: logger.debug("url='%s',headers()=%d,timeout(%d)='%s' - CALLED!", url, len(headers), len(timeout), timeout) if not isinstance(url, str): - raise ValueError(f"Parameter url[]='{type(url)}' is not 'str'") + raise ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'") elif url == "": raise ValueError("Parameter 'url' is empty") elif not isinstance(headers, dict): - raise ValueError(f"Parameter headers[]='{type(headers)}' is not 'dict'") + raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'") elif not isinstance(timeout, tuple): - raise ValueError(f"Parameter timeout[]='{type(timeout)}' is not 'tuple'") + raise ValueError(f"Parameter timeout[]='{type(timeout)}' is not of type 'tuple'") logger.debug("Parsing url='%s' ...", url) components = urlparse(url) @@ -77,7 +77,7 @@ def process_domain(domain: str, blocker: str, command: str) -> bool: domain_helper.raise_on(blocker) if not isinstance(command, str): - raise ValueError(f"Parameter command[]='{type(command)}' is not 'str'") + raise ValueError(f"Parameter command[]='{type(command)}' is not of type 'str'") elif command == "": raise ValueError("Parameter 'command' is empty") @@ -116,9 +116,9 @@ def process_domain(domain: str, blocker: str, command: str) -> bool: def find_domains(tags: bs4.element.ResultSet, search: str) -> list: logger.debug("tags[%s]()=%d,search='%s' - CALLED!", type(tags), len(tags), search) if not isinstance(tags, bs4.element.ResultSet): - raise ValueError(f"Parameter tags[]='{type(tags)}' is not 'ResultSet'") + raise ValueError(f"Parameter tags[]='{type(tags)}' is not of type 'ResultSet'") elif not isinstance(search, str): - raise ValueError(f"Parameter search[]='{type(search)}' is not 'str'") + raise ValueError(f"Parameter search[]='{type(search)}' is not of type 'str'") elif search == "": raise ValueError("Parameter 'search' is empty") @@ -148,7 +148,7 @@ def is_domain_wanted(domain: str) -> bool: wanted = True if not isinstance(domain, str): - raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") + raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'") elif domain == "": raise ValueError("Parameter 'domain' is empty") elif domain.lower() != domain: -- 2.39.5