]> git.mxchange.org Git - fba.git/commitdiff
Continued: master
authorRoland Häder <roland@mxchange.org>
Tue, 19 Aug 2025 19:25:46 +0000 (21:25 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 19 Aug 2025 22:43:27 +0000 (00:43 +0200)
- renamed parameter `domain` to `pattern`
- initialized `domain` with value from `pattern`
- some better error messages
- only invoke `utils.obfuscate()` when an asterisk or question mark is included
  in pattern

19 files changed:
fba/helpers/blocks.py
fba/helpers/cache.py
fba/helpers/config.py
fba/helpers/cookies.py
fba/helpers/dicts.py
fba/helpers/domain.py
fba/helpers/processing.py
fba/helpers/software.py
fba/helpers/tidyup.py
fba/http/csrf.py
fba/http/federation.py
fba/http/network.py
fba/http/nodeinfo.py
fba/models/blocks.py
fba/models/instances.py
fba/models/obfuscation.py
fba/networks/lemmy.py
fba/networks/misskey.py
fba/utils.py

index 196e8f0605a81b6282b6db93b2e374200727e8c5..693ab887edcc63ade356bb5c3f1474d3231dfccb 100644 (file)
@@ -27,7 +27,7 @@ def alias_block_level(block_level: str) -> str:
     logger.debug("block_level='%s' - CALLED!", block_level)
 
     if not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level in ["accept", "accepted"]:
         raise RuntimeError(f"Parameter block_level='{block_level}' is 'accept(ed)' but function was invoked")
     elif block_level == "silence":
index 8cfe2c3c716de72f08a0830daf7e340a1680d579..e81fb142718c3d8efe65552038f081873570c909 100644 (file)
@@ -35,7 +35,7 @@ def set_all(key: str, rows: list, value: any) -> None:
     logger.debug("key='%s',rows()=%d,value[]='%s' - CALLED!", key, len(rows), type(value))
 
     if not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif not key_exists(key):
         logger.debug("Cache for key='%s' not initialized.", key)
         _cache[key] = {}
@@ -55,9 +55,9 @@ def set_sub_key(key: str, sub: str, value: any) -> None:
     logger.debug("key='%s',sub='%s',value[]='%s' - CALLED!", key, sub, type(value))
 
     if not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif not isinstance(sub, str):
-        raise TypeError(f"Parameter sub[]='{type(sub)}' has not expected type 'str'")
+        raise TypeError(f"Parameter sub[]='{type(sub)}' is not of expected type 'str'")
     elif not key_exists(key):
         raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
 
@@ -70,9 +70,9 @@ def sub_key_exists(key: str, sub: str) -> bool:
     logger.debug("key='%s',sub='%s' - CALLED!", key, sub)
 
     if not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif not isinstance(sub, str):
-        raise TypeError(f"Parameter sub[]='{type(sub)}' has not expected type 'str'")
+        raise TypeError(f"Parameter sub[]='{type(sub)}' is not of expected type 'str'")
     elif not key_exists(key):
         raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
 
index e4fa73f39358d953e97f51fec1a78c41ad7c176a..947a072e81b07d0ff76d1e361119276ed9053513 100644 (file)
@@ -44,7 +44,7 @@ def get(key: str) -> any:
     logger.debug("key[%s]='%s' - CALLED!", type(key), key)
 
     if not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is an empty string")
     elif not key in _config:
index f768d9ea95662660e95e811492050cd92f2e149a..6f5637bfa3dd9cf8d0d02bef3df0d90383ecc491 100644 (file)
@@ -33,7 +33,7 @@ def store(domain: str, cookies: dict):
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(cookies, dict):
-        raise TypeError(f"Parameter cookies[]='{type(cookies)}' has not expected type 'dict'")
+        raise TypeError(f"Parameter cookies[]='{type(cookies)}' is not of expected type 'dict'")
 
     logger.debug("Setting %d cookie(s) for domain='%s'", len(cookies), domain)
     _cookies[domain] = cookies
index f8676721f7790988c4105b6b9f24156ed953d487..34636bb6dcbc616f7b2466350c7f379d514c6ada 100644 (file)
@@ -24,9 +24,9 @@ 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 TypeError(f"Parameter lists[]='{type(lists)}' has not expected type 'list'")
+        raise TypeError(f"Parameter lists[]='{type(lists)}' is not of expected type 'list'")
     elif not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is an empty string")
 
@@ -36,7 +36,7 @@ def has_key(lists: list, key: str, value: any) -> bool:
         logger.debug("row[%s]='%s", type(row), row)
 
         if not isinstance(row, dict):
-            raise TypeError(f"row[]='{type(row)}' has not expected type 'dict'")
+            raise TypeError(f"row[]='{type(row)}' is not of expected type 'dict'")
         elif not key in row:
             raise KeyError(f"Cannot find key='{key}'")
         elif row[key] == value:
index ec3da8d1ef2c2f35ed462616221fddd857cfd7dc..5533c7bf1c76912928804156bd0c37051e93edab 100644 (file)
@@ -37,7 +37,7 @@ def raise_on(domain: str) -> None:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is an empty string")
     elif domain.lower() != domain:
@@ -65,7 +65,7 @@ def is_in_url(domain: str, url: str) -> bool:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(url, str):
-        raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
@@ -87,7 +87,7 @@ def is_tld_wanted(domain: str) -> bool:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is an empty string")
 
@@ -114,7 +114,7 @@ def is_wanted(domain: str) -> bool:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise TypeError(f"Parameter domain[]='{type(domain)}' has not expected type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of expected type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is an empty string")
 
index 9f7ce9f7759af96d7d7f6b1010dde97a49270af5..438bddf352b166976443109dd4724d15653972ad 100644 (file)
@@ -47,7 +47,7 @@ def process_instance(blocked: str, blocker: str, command: str, force: bool = Fal
     domain_helper.raise_on(blocker)
 
     if not isinstance(command, str):
-        raise TypeError(f"Parameter command[]='{type(command)}' has not expected type 'str'")
+        raise TypeError(f"Parameter command[]='{type(command)}' is not of expected type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is an empty string")
     elif blacklist.is_blacklisted(blocked):
@@ -55,9 +55,10 @@ def process_instance(blocked: str, blocker: str, command: str, force: bool = Fal
     elif blacklist.is_blacklisted(blocker):
         raise RuntimeError(f"blocker='{blocker}' is blacklisted but function was invoked")
 
-    logger.debug("blocked='%s' - BEFORE!", blocked)
-    blocked = utils.deobfuscate(blocked, blocker)
-    logger.debug("blocked='%s' - AFTER!", blocked)
+    if blocked.find("*") >= 0 or blocked.find("?") >= 0:
+        logger.debug("blocked='%s' - BEFORE!", blocked)
+        blocked = utils.deobfuscate(blocked, blocker)
+        logger.debug("blocked='%s' - AFTER!", blocked)
 
     logger.debug("Checking if blocker='%s' has pending data ...", blocker)
     if instances.is_registered(blocker) and instances.has_pending(blocker):
@@ -97,9 +98,9 @@ def process_block(blocker: str, blocked: str, reason: str, block_level: str) ->
     domain_helper.raise_on(blocked)
 
     if not isinstance(reason, str) and reason is not None:
-        raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+        raise TypeError(f"Parameter reason[]='{type(reason)}' is not of expected type 'str'")
     elif not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter block_level is empty")
     elif block_level in ["reject", "suspend", "accept", "silence", "nsfw", "quarantined_instances"]:
@@ -130,13 +131,13 @@ def csv_block(blocker: str, url: str, command: str) -> None:
     domain_helper.raise_on(blocker)
 
     if not isinstance(url, str):
-        raise TypeError(f"url[]='{url}' has not expected type 'str'")
+        raise TypeError(f"url[]='{url}' is not of expected type 'str'")
     elif url in [None, ""]:
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(command, str):
-        raise TypeError(f"command[]='{command}' has not expected type 'str'")
+        raise TypeError(f"command[]='{command}' is not of expected type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is an empty string")
     elif blacklist.is_blacklisted(blocker):
@@ -175,7 +176,7 @@ def csv_block(blocker: str, url: str, command: str) -> None:
         elif "severity" in row:
             severity = blocks_helper.alias_block_level(row["severity"])
         else:
-            logger.debug("row='%s' does not contain severity column, setting 'reject'", row)
+            logger.debug("row='%s' does not contain severity column, setting 'rejected'", row)
             severity = "rejected"
 
         if "reason" in row and row["reason"] not in [None, ""]:
@@ -209,7 +210,7 @@ def csv_block(blocker: str, url: str, command: str) -> None:
             logger.debug("domain='%s' has an unwanted TLD - SKIPPED!", domain)
             continue
         elif domain.find("*") >= 0 or domain.find("?") >= 0:
-            logger.debug("domain='%s' is obfuscated - Invoking utils.deobfuscate(%s, %s) ...", domain, domain, blocker)
+            logger.debug("domain='%s' - BEFORE!", domain)
             domain = utils.deobfuscate(domain, blocker)
             logger.debug("domain='%s' - AFTER!", domain)
 
@@ -271,13 +272,13 @@ def csv_instance(instance: str, url: str, command: str) -> None:
     domain_helper.raise_on(instance)
 
     if not isinstance(url, str):
-        raise TypeError(f"url[]='{url}' has not expected type 'str'")
+        raise TypeError(f"url[]='{url}' is not of expected type 'str'")
     elif url in [None, ""]:
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(command, str):
-        raise TypeError(f"command[]='{command}' has not expected type 'str'")
+        raise TypeError(f"command[]='{command}' is not of expected type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is an empty string")
     elif blacklist.is_blacklisted(instance):
@@ -319,7 +320,7 @@ def csv_instance(instance: str, url: str, command: str) -> None:
             logger.debug("domain='%s' has an unwanted TLD - SKIPPED!", domain)
             continue
         elif domain.find("*") >= 0 or domain.find("?") >= 0:
-            logger.debug("domain='%s' is obfuscated - Invoking utils.deobfuscate(%s, %s) ...", domain, domain, instance)
+            logger.debug("domain='%s' - BEFORE!", domain)
             domain = utils.deobfuscate(domain, instance)
             logger.debug("domain='%s' - AFTER!", domain)
 
index f84476c36c0f29eedf27c85ee518e84db9910f13..24158ee80195f269ac6f1548172abd6df58b9bad 100644 (file)
@@ -225,7 +225,7 @@ def strip_hosted_on(software: str) -> str:
     logger.debug("software='%s' - CALLED!", software)
 
     if not isinstance(software, str):
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
     elif "hosted on" not in software:
@@ -250,7 +250,7 @@ def strip_powered_by(software: str) -> str:
     logger.debug("software='%s' - CALLED!", software)
 
     if not isinstance(software, str):
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
     elif "powered by" not in software:
@@ -275,11 +275,11 @@ def strip_until(software: str, until: str) -> str:
     logger.debug("software='%s',until='%s' - CALLED!", software, until)
 
     if not isinstance(software, str):
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
     elif not isinstance(until, str):
-        raise TypeError(f"Parameter until[]='{type(until)}' has not expected type 'str'")
+        raise TypeError(f"Parameter until[]='{type(until)}' is not of expected type 'str'")
     elif until == "":
         raise ValueError("Parameter 'until' is an empty string")
     elif not until in software:
index 1593e46496f42db4f0b793087ae3eccb036a4087..564f5fd150a5fb2772a2f95bf87acabd2c11d552 100644 (file)
@@ -25,7 +25,7 @@ def reason(string: str) -> str:
     logger.debug("string='%s' - CALLED!", string)
 
     if not isinstance(string, str):
-        raise TypeError(f"Parameter string[]='{type(string)}' has not expected type 'str'")
+        raise TypeError(f"Parameter string[]='{type(string)}' is not of expected type 'str'")
 
     # Strip string
     string = string.strip()
@@ -42,7 +42,7 @@ def domain(string: str) -> str:
     logger.debug("string='%s' - CALLED!", string)
 
     if not isinstance(string, str):
-        raise TypeError(f"Parameter string[]='{type(string)}' has not expected type 'str'")
+        raise TypeError(f"Parameter string[]='{type(string)}' is not of expected type 'str'")
     elif string == "":
         raise ValueError("Parameter 'string' is an empty string")
 
index 8a487dfcc7b3e4de8c1cf956e435d007b89dbefa..c68f9477c28b64152f4c363d5041521525a159ca 100644 (file)
@@ -39,7 +39,7 @@ def determine(domain: str, headers: dict) -> dict:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(headers, dict):
-        raise TypeError(f"Parameter headers[]='{type(headers)}' has not expected type 'dict'")
+        raise TypeError(f"Parameter headers[]='{type(headers)}' is not of expected type 'dict'")
 
     # Default headers with no CSRF
     reqheaders = headers
index 2e2e2813c4d10b43d399b04a50a03ca0c423f22b..46171f507e22fce4bfb3fa8b0b6c25b2288b2944 100644 (file)
@@ -65,15 +65,15 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(origin, str) and origin is not None:
-        raise TypeError(f"Parameter origin[]='{type(origin)}' has not expected type 'str'")
+        raise TypeError(f"Parameter origin[]='{type(origin)}' is not of expected type 'str'")
     elif not isinstance(command, str):
-        raise TypeError(f"Parameter command[]='{type(command)}' has not expected type 'str'")
+        raise TypeError(f"Parameter command[]='{type(command)}' is not of expected type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is an empty string")
     elif command in ["fetch_blocks", "fetch_cs", "fetch_bkali", "fetch_relays", "fetch_fedipact", "fetch_joinmobilizon", "fetch_joinmisskey", "fetch_joinfediverse", "fetch_relaylist"] and origin is None:
         raise ValueError(f"Parameter command='{command}' but origin is None, please fix invoking this function.")
     elif not isinstance(path, str) and path is not None:
-        raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
     elif path is not None and not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with a slash")
     elif _DEPTH > 0 and instances.is_recent(domain, "last_instance_fetch"):
@@ -90,7 +90,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
     elif software is None:
         logger.debug("domain='%s' has unknown software or nodeinfo has recently being fetched", domain)
     elif not isinstance(software, str):
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
 
     logger.debug("domain='%s' - BEFORE!", domain)
     instance = domain_helper.encode_idna(domain.split("?")[0])
@@ -231,13 +231,13 @@ def fetch_peers(domain: str, software: str, origin: str) -> list:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(software, str) and software is not None:
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif isinstance(software, str) and software == "":
         raise ValueError("Parameter 'software' is an empty string")
     elif software is not None and software_helper.is_relay(software):
         raise RuntimeError(f"domain='{domain}' is of software='{software}' and isn't supported here.")
     elif not isinstance(origin, str) and origin is not None:
-        raise TypeError(f"Parameter origin[]='{type(origin)}' has not expected type 'str'")
+        raise TypeError(f"Parameter origin[]='{type(origin)}' is not of expected type 'str'")
     elif isinstance(origin, str) and origin == "":
         raise ValueError("Parameter 'origin' is an empty string")
 
@@ -284,7 +284,7 @@ def fetch_peers(domain: str, software: str, origin: str) -> list:
 
     logger.debug("peers[]='%s'", type(peers))
     if not isinstance(peers, list):
-        logger.warning("peers[]='%s' has not expected type 'list', maybe bad API response?", type(peers))
+        logger.warning("peers[]='%s' is not of expected type 'list', maybe bad API response?", type(peers))
         peers = []
 
     logger.debug("Invoking instances.set_total_peers(%s,%d) ...", domain, len(peers))
@@ -300,7 +300,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is an empty string")
     elif not path.startswith("/"):
@@ -403,7 +403,7 @@ def determine_software(domain: str, path: str = None) -> str:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str) and path is not None:
-        raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
     elif path is not None and not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with a slash")
 
@@ -565,7 +565,7 @@ def add_peers(rows: dict) -> list:
     logger.debug("rows[]='%s' - CALLED!", type(rows))
 
     if not isinstance(rows, dict):
-        raise TypeError(f"Parameter rows[]='{type(rows)}' has not expected type 'dict'")
+        raise TypeError(f"Parameter rows[]='{type(rows)}' is not of expected type 'dict'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is an empty string")
 
index 56049a5a419e1fa61a8ea3446d0637bf426b3287..7da2efd787139186b613f6629eaee80f496c17bf 100644 (file)
@@ -75,15 +75,15 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = {}) ->
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is empty")
     elif not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with / but should")
     elif not isinstance(data, str):
-        raise TypeError(f"data[]='{type(data)}' has not expected type 'str'")
+        raise TypeError(f"data[]='{type(data)}' is not of expected type 'str'")
     elif headers is not None and not isinstance(headers, dict):
-        raise ValueError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+        raise ValueError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
 
     json_reply = {
         "status_code": 200,
@@ -139,13 +139,13 @@ 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 TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(timeout, tuple):
-        raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
 
     json_reply = {
        "status_code": 200,
@@ -183,15 +183,15 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is empty")
     elif not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with / but should")
     elif not isinstance(headers, dict):
-        raise TypeError(f"headers[]='{type(headers)}' has not expected type 'list'")
+        raise TypeError(f"headers[]='{type(headers)}' is not of expected type 'list'")
     elif not isinstance(timeout, tuple):
-        raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
 
     json_reply = {
         "status_code": 200,
@@ -242,7 +242,7 @@ def send_bot_post(domain: str, blocklist: list) -> None:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(blocklist, list):
-        raise TypeError(f"Parameter blocklist[]='{type(blocklist)}' has not expected type 'list'")
+        raise TypeError(f"Parameter blocklist[]='{type(blocklist)}' is not of expected type 'list'")
     elif len(blocklist) == 0:
         raise ValueError("Parameter 'blocklist' is an empty string")
     elif config.get("bot_token") == "":
@@ -294,17 +294,17 @@ def _fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is an empty string")
     elif not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with / but should")
     elif not isinstance(headers, dict):
-        raise TypeError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+        raise TypeError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
     elif not isinstance(timeout, tuple):
-        raise TypeError(f"timeout[]='{type(timeout)}' has not expected type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of expected type 'tuple'")
     elif not isinstance(allow_redirects, bool):
-        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
 
     start = 0
     try:
@@ -341,17 +341,17 @@ def fetch_url(url: str, headers: dict, timeout: tuple, allow_redirects: bool = T
     logger.debug("url='%s',headers()=%d,timeout(%d)='%s',allow_redirects='%s' - CALLED!", url, len(headers), len(timeout), timeout, allow_redirects)
 
     if not isinstance(url, str):
-        raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(headers, dict):
-        raise TypeError(f"Parameter headers[]='{type(headers)}' has not expected type 'dict'")
+        raise TypeError(f"Parameter headers[]='{type(headers)}' is not of expected type 'dict'")
     elif not isinstance(timeout, tuple):
-        raise TypeError(f"Parameter timeout[]='{type(timeout)}' has not expected type 'tuple'")
+        raise TypeError(f"Parameter timeout[]='{type(timeout)}' is not of expected type 'tuple'")
     elif not isinstance(allow_redirects, bool):
-        raise TypeError(f"Parameter allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+        raise TypeError(f"Parameter allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
 
     logger.debug("Parsing url='%s' ...", url)
     components = urllib.parse.urlparse(url)
@@ -384,21 +384,21 @@ def fetch_json_rows(hostname: str, path: str, headers: dict = {}, rows_key: str
     logger.debug("hostname='%s',path='%s',headers()=%d,rows_key='%s' - CALLED!", hostname, path, len(headers), rows_key)
 
     if not isinstance(hostname, str):
-        raise TypeError(f"hostname[]='{type(hostname)}' has not expected type 'str'")
+        raise TypeError(f"hostname[]='{type(hostname)}' is not of expected type 'str'")
     elif hostname == "":
         raise ValueError("Parameter 'hostname' is an empty string")
     elif not validators.hostname(hostname):
         raise ValueError(f"hostname='{hostname}' is not a valid hostname")
     elif not isinstance(path, str):
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is an empty string")
     elif not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with a slash")
     elif headers is not None and not isinstance(headers, dict):
-        raise ValueError(f"headers[]='{type(headers)}' has not expected type 'dict'")
+        raise ValueError(f"headers[]='{type(headers)}' is not of expected type 'dict'")
     elif not isinstance(rows_key, str) and rows_key is not None:
-        raise TypeError(f"rows_key[]='{type(rows_key)}' has not expected type 'str'")
+        raise TypeError(f"rows_key[]='{type(rows_key)}' is not of expected type 'str'")
     elif rows_key is not None and rows_key == "":
         raise ValueError("Parameter 'rows_key' is an empty string")
 
@@ -435,7 +435,7 @@ def fetch_csv_rows (url: str) -> list:
     logger.debug("url='%s' - CALLED!", url)
 
     if not isinstance(url, str):
-        raise TypeError(f"url[]='{type(url)}' has not expected type 'str'")
+        raise TypeError(f"url[]='{type(url)}' is not of expected type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is an empty string")
     elif not validators.url(url):
@@ -477,13 +477,13 @@ def get_generic(domain: str, path: str, allow_redirects: bool = False) -> reques
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is an empty string")
     elif not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with / but should")
     elif not isinstance(allow_redirects, bool):
-        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' has not expected type 'bool'")
+        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of expected type 'bool'")
 
     logger.debug("Fetching path='%s' from domain='%s' ...", path, domain)
     response = _fetch_response(
index 11fadf912abfeb64c336a2836a861433b13b57f5..b35579e042745af398066b37aec2b0d3d05956a0 100644 (file)
@@ -67,11 +67,11 @@ def fetch(domain: str, path: str = None, update_mode: bool = True) -> dict:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str) and path is not None:
-        raise TypeError(f"Parameter path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of expected type 'str'")
     elif path is not None and not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with a slash")
     elif not isinstance(update_mode, bool) and update_mode is not None:
-        raise TypeError(f"Parameter update_mode[]='{type(update_mode)}' has not expected type 'bool'")
+        raise TypeError(f"Parameter update_mode[]='{type(update_mode)}' is not of expected type 'bool'")
 
     if path is None and update_mode:
         logger.debug("Fetching well-known nodeinfo from domain='%s' ...", domain)
@@ -207,7 +207,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict:
             for link in infos["links"]:
                 logger.debug("link[%s]='%s'", type(link), link)
                 if not isinstance(link, dict) or not "rel" in link:
-                    logger.debug("link[]='%s' has not expected type 'dict' or no element 'rel' found - SKIPPED!", type(link))
+                    logger.debug("link[]='%s' is not of expected 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)
index b4eb2f5c576a155b038c78a5e76f93522c995d64..c9500928cdc1b4f3ed2af9ea6e0915f3c262ad1e 100644 (file)
@@ -34,7 +34,7 @@ def get_reason(blocker: str, blocked: str, block_level: str) -> str:
     domain_helper.raise_on(blocked)
 
     if not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is an empty string")
     elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
@@ -67,9 +67,9 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str) ->
     domain_helper.raise_on(blocked)
 
     if not isinstance(reason, str) and reason is not None:
-        raise TypeError(f"Parameter reason[]='{type(reason)}' has not expected type 'str'")
+        raise TypeError(f"Parameter reason[]='{type(reason)}' is not of expected type 'str'")
     elif not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is an empty string")
     elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
@@ -100,7 +100,7 @@ def update_last_seen(blocker: str, blocked: str, block_level: str) -> None:
     domain_helper.raise_on(blocked)
 
     if not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is an empty string")
     elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
@@ -129,7 +129,7 @@ def is_instance_blocked(blocker: str, blocked: str, block_level: str = None) ->
     domain_helper.raise_on(blocked)
 
     if not isinstance(block_level, str) and block_level is not None:
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is an empty string")
     elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
@@ -168,7 +168,7 @@ def add(blocker: str, blocked: str, reason: str, block_level: str) -> None:
     domain_helper.raise_on(blocked)
 
     if not isinstance(block_level, str):
-        raise TypeError(f"Parameter block_level[]='{type(block_level)}' has not expected type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of expected type 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is an empty string")
     elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
@@ -205,11 +205,11 @@ def valid(value: str, column: str) -> bool:
     logger.debug("value='%s',column='%s' - CALLED!", value, column)
 
     if not isinstance(value, str):
-        raise TypeError(f"Parameter value[]='{type(value)}' has not expected type 'str'")
+        raise TypeError(f"Parameter value[]='{type(value)}' is not of expected type 'str'")
     elif value == "":
         raise ValueError("Parameter 'value' is an empty string")
     elif not isinstance(column, str):
-        raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is an empty string")
 
@@ -227,11 +227,11 @@ def translate_idnas(rows: list, column: str) -> None:
     logger.debug("rows[]='%s',column='%s' - CALLED!", type(rows), column)
 
     if not isinstance(rows, list):
-        raise TypeError(f"rows[]='{type(rows)}' has not expected type 'list'")
+        raise TypeError(f"rows[]='{type(rows)}' is not of expected type 'list'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is an empty list")
     elif not isinstance(column, str):
-        raise TypeError(f"column='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"column='{type(column)}' is not of expected type 'str'")
     elif column not in ["blocker", "blocked"]:
         raise ValueError(f"column='{column}' is not supported")
 
index 50789fc6e456b29f832ec998d74dab4d4898ec57..900a7aa695b32cb35db540401fa78a7d4a4ed448 100644 (file)
@@ -92,7 +92,7 @@ def _set_pending_data(key: str, domain: str, value: any) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(key, str):
-        raise TypeError(f"Parameter key[]='{type(key)}' has not expected type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of expected type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is empty")
     elif not key in _pending:
@@ -189,21 +189,21 @@ 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 TypeError(f"origin[]='{type(origin)}' has not expected type 'str'")
+        raise TypeError(f"origin[]='{type(origin)}' is not of expected type 'str'")
     elif origin == "":
         raise ValueError("Parameter 'origin' is empty")
     elif not isinstance(command, str):
-        raise TypeError(f"command[]='{type(command)}' has not expected type 'str'")
+        raise TypeError(f"command[]='{type(command)}' is not of expected type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
     elif not isinstance(path, str) and path is not None:
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is empty")
     elif path is not None and not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with / but should")
     elif not isinstance(software, str) and software is not None:
-        raise TypeError(f"software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
     elif origin is not None and not validators.domain(origin.split("/")[0], rfc_2782=True):
@@ -353,7 +353,7 @@ def is_recent(domain: str, column: str = "last_instance_fetch") -> bool:
     domain_helper.raise_on(domain)
 
     if not isinstance(column, str):
-        raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
     elif not column.startswith("last_"):
         raise ValueError(f"Parameter column='{column}' is not expected")
     elif blacklist.is_blacklisted(domain):
@@ -388,7 +388,7 @@ def deobfuscate(char: str, domain: str, blocked_hash: str = None) -> tuple:
     logger.debug("char='%s',domain='%s',blocked_hash='%s' - CALLED!", char, domain, blocked_hash)
 
     if not isinstance(char, str):
-        raise TypeError(f"Parameter char[]='{type(char)}' has not expected type 'str'")
+        raise TypeError(f"Parameter char[]='{type(char)}' is not of expected type 'str'")
     elif char == "":
         raise ValueError("Parameter 'char' is an empty string")
     elif not isinstance(domain, str):
@@ -398,7 +398,7 @@ def deobfuscate(char: str, domain: str, blocked_hash: str = None) -> tuple:
     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 TypeError(f"Parameter blocked_hash[]='{type(blocked_hash)}' has not expected type 'str'")
+        raise TypeError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not of expected type 'str'")
 
     # Init variables
     row = None
@@ -450,7 +450,7 @@ def set_last_response_time(domain: str, response_time: float) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(response_time, float):
-        raise TypeError(f"response_time[]='{type(response_time)}' has not expected type 'float'")
+        raise TypeError(f"response_time[]='{type(response_time)}' is not of expected type 'float'")
     elif response_time < 0:
         raise ValueError(f"response_time={response_time} is below zero")
 
@@ -480,7 +480,7 @@ def set_last_offset(domain: str, offset: int) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(offset, int):
-        raise TypeError(f"offset[]='{type(offset)}' has not expected type 'float'")
+        raise TypeError(f"offset[]='{type(offset)}' is not of expected type 'float'")
     elif offset < 0:
         raise ValueError(f"offset={offset} is below zero")
 
@@ -493,7 +493,7 @@ def set_last_requested_path(domain: str, path: float) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(path, str):
-        raise TypeError(f"path[]='{type(path)}' has not expected type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of expected type 'str'")
     elif path == "":
         raise ValueError(f"path='{path}' is an empty string")
     elif not path.startswith("/"):
@@ -508,7 +508,7 @@ def set_total_peers(domain: str, peers: list) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(peers, list):
-        raise TypeError(f"Parameter peers[]='{type(peers)}' has not expected type 'list'")
+        raise TypeError(f"Parameter peers[]='{type(peers)}' is not of expected type 'list'")
 
     # Set timestamp
     _set_pending_data("total_peers", domain, len(peers))
@@ -519,7 +519,7 @@ def set_total_blocks(domain: str, blocks: list) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(blocks, list):
-        raise TypeError(f"Parameter blocks[]='{type(blocks)}' has not expected type 'list'")
+        raise TypeError(f"Parameter blocks[]='{type(blocks)}' is not of expected type 'list'")
 
     # Set timestamp
     _set_pending_data("total_blocks", domain, len(blocks))
@@ -530,7 +530,7 @@ def set_obfuscated_blocks(domain: str, obfuscated: int) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(obfuscated, int):
-        raise TypeError(f"Parameter obfuscated[]='{type(obfuscated)}' has not expected type 'int'")
+        raise TypeError(f"Parameter obfuscated[]='{type(obfuscated)}' is not of expected type 'int'")
     elif obfuscated < 0:
         raise ValueError(f"Parameter obfuscated={obfuscated} is not valid")
 
@@ -543,7 +543,7 @@ def set_nodeinfo_url(domain: str, url: str) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(url, str) and url is not None:
-        raise TypeError(f"Parameter url[]='{type(url)}' has not expected type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of expected type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is an empty string")
     elif url is not None and not validators.url(url):
@@ -558,7 +558,7 @@ def set_detection_mode(domain: str, mode: str) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(mode, str) and mode is not None:
-        raise TypeError(f"Parameter mode[]='{type(mode)}' has not expected type 'str'")
+        raise TypeError(f"Parameter mode[]='{type(mode)}' is not of expected type 'str'")
     elif mode == "":
         raise ValueError("Parameter 'mode' is an empty string")
 
@@ -571,7 +571,7 @@ def set_has_obfuscation(domain: str, has_obfuscation: bool) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(has_obfuscation, bool):
-        raise TypeError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' has not expected type 'bool'")
+        raise TypeError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' is not of expected type 'bool'")
 
     # Set timestamp
     _set_pending_data("has_obfuscation", domain, has_obfuscation)
@@ -582,7 +582,7 @@ def set_original_software(domain: str, software: str) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(software, str) and software is not None:
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
 
@@ -595,7 +595,7 @@ def set_software(domain: str, software: str) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(software, str) and software is not None:
-        raise TypeError(f"Parameter software[]='{type(software)}' has not expected type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of expected type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
 
@@ -607,11 +607,11 @@ def valid(value: str, column: str) -> bool:
     logger.debug("value='%s',column='%s' - CALLED!", value, column)
 
     if not isinstance(value, str):
-        raise TypeError(f"Parameter value[]='{type(value)}' has not expected type 'str'")
+        raise TypeError(f"Parameter value[]='{type(value)}' is not of expected type 'str'")
     elif value == "":
         raise ValueError("Parameter 'value' is an empty string")
     elif not isinstance(column, str):
-        raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is an empty string")
 
@@ -629,7 +629,7 @@ def delete(search: str, column: str = "domain") -> None:
     logger.debug("search='%s, column='%s'' - CALLED!", search, column)
 
     if not isinstance(column, str):
-        raise TypeError(f"Parameter column[]='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of expected type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is an empty string")
     elif column in ["domain", "origin"]:
@@ -646,11 +646,11 @@ def translate_idnas(rows: list, column: str) -> None:
     logger.debug("rows[]='%s',column='%s' - CALLED!", type(rows), column)
 
     if not isinstance(rows, list):
-        raise TypeError("rows[]='{type(rows)}' has not expected type 'list'")
+        raise TypeError("rows[]='{type(rows)}' is not of expected type 'list'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is an empty list")
     elif not isinstance(column, str):
-        raise TypeError(f"column='{type(column)}' has not expected type 'str'")
+        raise TypeError(f"column='{type(column)}' is not of expected type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is an empty string")
     elif column not in ["domain", "origin"]:
index 958f3a377757ec08b14347bd831749acf7550851..854e6c9873f9c97f3bed4ad35a16a64307e6c006 100644 (file)
@@ -28,7 +28,7 @@ def has(pattern: str) -> bool:
     logger.debug("pattern='%s' - CALLED!", pattern)
 
     if not isinstance(pattern, str):
-        raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
 
@@ -46,7 +46,7 @@ def add(pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
 
     if not isinstance(pattern, str):
-        raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif has(pattern):
@@ -63,7 +63,7 @@ def update (pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
 
     if not isinstance(pattern, str):
-        raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif not has(pattern):
@@ -80,7 +80,7 @@ def delete (pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
 
     if not isinstance(pattern, str):
-        raise TypeError(f"pattern[]='{type(pattern)}' has not expected type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of expected type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif not has(pattern):
index 82a1f9296d4b108c47a830df3837bc91a034b6c1..c6e993b9f7cb96e94cb17129db6952973bcce25d 100644 (file)
@@ -322,9 +322,9 @@ def parse_script(doc: bs4.BeautifulSoup, only: str = None) -> list:
     logger.debug("doc[]='%s',only='%s' - CALLED!", type(doc), only)
 
     if not isinstance(doc, bs4.BeautifulSoup):
-        raise TypeError(f"Parameter doc[]='{type(only)}' has not expected type 'bs4.BeautifulSoup'")
+        raise TypeError(f"Parameter doc[]='{type(only)}' is not of expected type 'bs4.BeautifulSoup'")
     elif not isinstance(only, str) and only is not None:
-        raise TypeError(f"Parameter only[]='{type(only)}' has not expected type 'str'")
+        raise TypeError(f"Parameter only[]='{type(only)}' is not of expected type 'str'")
     elif isinstance(only, str) and only == "":
         raise ValueError("Parameter 'only' is an empty string")
 
index 5406bf51072615816e0ff799f7dfac908a27cfdc..7ed706504a9cc190f2daead967c79b72f20d3c39 100644 (file)
@@ -118,7 +118,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' has not expected type 'str' - SKIPPED!", type(row["host"]))
+                logger.warning("row[host][]='%s' is not of expected type 'str' - SKIPPED!", type(row["host"]))
                 continue
             elif row["host"] == "":
                 logger.warning("row[host] is an empty string,domain='%s' - SKIPPED!", domain)
@@ -225,7 +225,7 @@ def fetch_blocks(domain: str) -> list:
                     logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance)
                     continue
                 elif not isinstance(instance["host"], str):
-                    logger.warning("instance[host][]='%s' has not expected type 'str' - SKIPPED!", type(instance["host"]))
+                    logger.warning("instance[host][]='%s' is not of expected type 'str' - SKIPPED!", type(instance["host"]))
                     continue
                 elif instance["host"] == "":
                     logger.warning("instance[host] is an empty string,domain='%s' - SKIPPED!", domain)
index a28a965993a385da1995d57b8db7a1068d5f970d..213ebaee57a2316ea59acbc5ff2299a03eb81880 100644 (file)
@@ -47,9 +47,9 @@ 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 TypeError(f"Parameter tags[]='{type(tags)}' has not expected type 'ResultSet'")
+        raise TypeError(f"Parameter tags[]='{type(tags)}' is not of expected type 'ResultSet'")
     elif not isinstance(search, str):
-        raise TypeError(f"Parameter search[]='{type(search)}' has not expected type 'str'")
+        raise TypeError(f"Parameter search[]='{type(search)}' is not of expected type 'str'")
     elif search == "":
         raise ValueError("Parameter 'search' is an empty string")
 
@@ -130,46 +130,49 @@ def add_all_to_list(domains: list, source: str, splitter: str) -> None:
 
     logger.debug("EXIT!")
 
-def deobfuscate(domain: str, blocker: str, domain_hash: str = None) -> str:
-    logger.debug("domain='%s',blocker='%s',domain_hash='%s' - CALLED!", domain, blocker, domain_hash)
+def deobfuscate(pattern: str, blocker: str, domain_hash: str = None) -> str:
+    logger.debug("pattern='%s',blocker='%s',domain_hash='%s' - CALLED!", pattern, blocker, domain_hash)
     domain_helper.raise_on(blocker)
 
-    if validators.domain(domain, rfc_2782=True) and blacklist.is_blacklisted(domain):
-        raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
+    if validators.domain(pattern, rfc_2782=True) and blacklist.is_blacklisted(pattern):
+        raise RuntimeError(f"pattern='{pattern}' is blacklisted but function was invoked")
     elif not isinstance(domain_hash, str) and domain_hash is not None:
-        raise TypeError(f"Parameter domain_hash[]='{type(domain_hash)}' has not expected type 'str'")
+        raise TypeError(f"Parameter domain_hash[]='{type(domain_hash)}' is not of expected type 'str'")
     elif domain_hash == "":
         raise ValueError("Parameter 'domain_hash' is an empty string")
 
-    logger.debug("Checking domain='%s' ...", domain)
-    if domain.find("*") >= 0:
+    # Init domain with current value (which might be a pattern)
+    domain = pattern
+
+    logger.debug("Checking pattern='%s' ...", pattern)
+    if pattern.find("*") >= 0:
         logger.debug("blocker='%s' uses obfuscated domains", blocker)
         instances.set_has_obfuscation(blocker, True)
 
         # Obscured domain name with no hash
-        row = instances.deobfuscate("*", domain, domain_hash)
+        row = instances.deobfuscate("*", pattern, domain_hash)
 
         logger.debug("row[]='%s'", type(row))
         if row is not None:
-            logger.debug("domain='%s' de-obscured to '%s'", domain, row["domain"])
+            logger.debug("pattern='%s' de-obscured to '%s'", pattern, row["domain"])
             domain = row["domain"]
         else:
-            logger.warning("blocker='%s' has domain='%s' that cannot be deobfuscated.", blocker, domain)
-    elif domain.find("?") >= 0:
+            logger.warning("blocker='%s' has pattern='%s' that cannot be deobfuscated.", blocker, pattern)
+    elif pattern.find("?") >= 0:
         logger.debug("blocker='%s' uses obfuscated domains", blocker)
         instances.set_has_obfuscation(blocker, True)
 
         # Obscured domain name with no hash
-        row = instances.deobfuscate("?", domain, domain_hash)
+        row = instances.deobfuscate("?", pattern, domain_hash)
 
         logger.debug("row[]='%s'", type(row))
         if row is not None:
-            logger.debug("domain='%s' de-obscured to '%s'", domain, row["domain"])
+            logger.debug("pattern='%s' de-obscured to '%s'", pattern, row["domain"])
             domain = row["domain"]
         else:
-            logger.warning("blocker='%s' has domain='%s' that cannot be deobfuscated.", blocker, domain)
+            logger.warning("blocker='%s' has pattern='%s' that cannot be deobfuscated.", blocker, pattern)
     else:
-        logger.debug("domain='%s' is not obfuscated", domain)
+        logger.warning("pattern='%s' is not supported, returning possibly obfuscated domain ...", pattern)
 
     logger.debug("domain='%s' - EXIT!", domain)
     return domain