]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 23:57:33 +0000 (00:57 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 23:57:33 +0000 (00:57 +0100)
- it is a type-check, not a value-range check

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/json.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/utils.py

index d9e610c439e3937495217d11f6d93e7ac2b7b423..f522d57a03ca8885edb229c8ce4912312ccdfa7d 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 ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
     elif block_level in ["accept", "accepted"]:
         raise ValueError(f"Parameter block_level='{block_level}' is 'accept(ed)' but function was invoked")
     elif block_level == "silence":
index 9f538abda0cdd11e2d9717bf582adb2e75e37a26..c9b234b8187bb0f45d4c01f1956cf8e801c00d8f 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 ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(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] = {}
@@ -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 ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of type 'str'")
     elif not isinstance(sub, str):
-        raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'")
+        raise TypeError(f"Parameter sub[]='{type(sub)}' is not of 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 ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of type 'str'")
     elif not isinstance(sub, str):
-        raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'")
+        raise TypeError(f"Parameter sub[]='{type(sub)}' is not of type 'str'")
     elif not key_exists(key):
         raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
 
index 215f0f01de32778bb07b5adc793bb8de7e067eeb..ac45e049194598fc14c51cd6a3b6828bd3840026 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 ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is empty")
     elif not key in _config:
index 8a34add3742b61ccb2fe3f7b3c156db27bc770fa..6b2cbff1cac68eabf95b4a6866dbe5d3e1df1f29 100644 (file)
@@ -33,7 +33,7 @@ def store(domain: str, cookies: dict):
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(cookies, dict):
-        raise ValueError(f"Parameter cookies[]='{type(cookies)}' is not of type 'dict'")
+        raise TypeError(f"Parameter cookies[]='{type(cookies)}' is not of type 'dict'")
 
     _cookies[domain] = cookies
 
index 7142b3fd5701d3ccbac5e3f635b01256af8b5537..d18f30d8574e9857a54661f45de2b03d0898ea82 100644 (file)
@@ -23,9 +23,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 ValueError(f"Parameter lists[]='{type(lists)}' is not of type 'list'")
+        raise TypeError(f"Parameter lists[]='{type(lists)}' is not of type 'list'")
     elif not isinstance(key, str):
-        raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is empty")
 
@@ -35,7 +35,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 ValueError(f"row[]='{type(row)}' is not of type 'dict'")
+            raise TypeError(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:
index 224b590bdc686236c03e3fb7777f27544a3b8286..9094663100d9cc266324d844e5f6b15b169af763 100644 (file)
@@ -34,7 +34,7 @@ def raise_on(domain: str) -> None:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
     elif domain.lower() != domain:
@@ -62,7 +62,7 @@ def is_in_url(domain: str, url: str) -> bool:
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(url, str):
-        raise ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is empty")
     elif not validators.url(url):
@@ -84,7 +84,7 @@ def is_tld_wanted(domain: str) -> bool:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
 
@@ -111,7 +111,7 @@ def is_wanted(domain: str) -> bool:
     logger.debug("domain='%s' - CALLED!", domain)
 
     if not isinstance(domain, str):
-        raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
 
index cc37e990211fb2ca8fbab718f211b6c8ce8be6f8..4323b27cea7b601712555a9668c45e78cad2a2f0 100644 (file)
@@ -27,7 +27,7 @@ def is_json_response(response: requests.models.Response) -> bool:
     logger.debug("response[]='%s' - CALLED!", type(response))
 
     if not isinstance(response, requests.models.Response):
-        raise ValueError(f"Parameter response[]='{type(response)}' is not type of 'Response'")
+        raise TypeError(f"Parameter response[]='{type(response)}' is not type of 'Response'")
     elif not response.ok or response.status_code > 200:
         raise ValueError(f"response.ok='{response.ok}',response.status_code={response.status_code},response.reason='{response.reason}' but function was invoked")
 
@@ -40,7 +40,7 @@ def from_response(response: requests.models.Response) -> any:
     logger.debug("response[]='%s' - CALLED!", type(response))
 
     if not isinstance(response, requests.models.Response):
-        raise ValueError(f"Parameter response[]='{type(response)}' is not type of 'Response'")
+        raise TypeError(f"Parameter response[]='{type(response)}' is not type of 'Response'")
     elif not response.ok or response.status_code > 200:
         raise ValueError(f"response.ok='{response.ok}',response.status_code={response.status_code},response.reason='{response.reason}' but function was invoked")
     elif response.text.strip() != "" and not is_json_response(response):
index 9832b64d826b3e87429104a3337dd1491d0ffafe..0acec17bcc8e5fe4af7d82526f3015cd526a2250 100644 (file)
@@ -44,7 +44,7 @@ def instance(blocked: str, blocker: str, command: str, force: bool = False) -> b
     domain_helper.raise_on(blocker)
 
     if not isinstance(command, str):
-        raise ValueError(f"Parameter command[]='{type(command)}' is not of type 'str'")
+        raise TypeError(f"Parameter command[]='{type(command)}' is not of type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
     elif blacklist.is_blacklisted(blocked):
@@ -94,9 +94,9 @@ def block(blocker: str, blocked: str, reason: str, block_level: str) -> bool:
     domain_helper.raise_on(blocked)
 
     if not isinstance(reason, str) and reason is not None:
-        raise ValueError(f"Parameter reason[]='{type(reason)}' is not of type 'str'")
+        raise TypeError(f"Parameter reason[]='{type(reason)}' is not of type 'str'")
     elif not isinstance(block_level, str):
-        raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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 ["reject", "suspend", "accept", "silence", "nsfw", "quarantined_instances"]:
@@ -127,13 +127,13 @@ def csv_block(blocker: str, url: str, command: str) -> None:
     domain_helper.raise_on(blocker)
 
     if not isinstance(url, str):
-        raise ValueError(f"url[]='{url}' is not of type 'str'")
+        raise TypeError(f"url[]='{url}' is not of type 'str'")
     elif url in [None, ""]:
         raise ValueError("Parameter 'url' is empty")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(command, str):
-        raise ValueError(f"command[]='{command}' is not of type 'str'")
+        raise TypeError(f"command[]='{command}' is not of type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
     elif blacklist.is_blacklisted(blocker):
index fe2a01aa66d055ad8b2eddb4962ff26ba19b9196..a258a517f11b5a8c3aeaae3a2d3963885e865418 100644 (file)
@@ -105,7 +105,7 @@ def alias(software: str) -> str:
     logger.debug("software='%s'- CALLED!", software)
 
     if not isinstance(software, str) and software is not None:
-        raise ValueError(f"software[]='{type(software)}' is not type 'str'")
+        raise TypeError(f"software[]='{type(software)}' is not type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
     elif software.startswith("re:"):
@@ -215,7 +215,7 @@ 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 of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
     elif "hosted on" not in software:
@@ -240,7 +240,7 @@ 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 of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
     elif "powered by" not in software:
@@ -265,11 +265,11 @@ 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 of type 'str'")
+        raise TypeError(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 of type 'str'")
+        raise TypeError(f"Parameter until[]='{type(until)}' is not of type 'str'")
     elif until == "":
         raise ValueError("Parameter 'until' is empty")
     elif not until in software:
@@ -290,7 +290,7 @@ def is_relay(software: str) -> bool:
     logger.debug("software='%s'- CALLED!", software)
 
     if not isinstance(software, str):
-        raise ValueError(f"software[]='{type(software)}' is not type 'str'")
+        raise TypError(f"software[]='{type(software)}' is not type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
 
@@ -303,7 +303,7 @@ def is_relay(software: str) -> bool:
 def remove_extras(software: str):
     logger.debug("software[%s]='%s' - CALLED!", type(software), software)
     if not isinstance(software, str):
-        raise ValueError(f"software[]='%s' is not type of 'str'", type(software))
+        raise TypeError(f"software[]='%s' is not type of 'str'", type(software))
 
     if software == "":
         logger.debug("Corrected empty string to None for software.")
index be7503d85013ab50f0df7bb03d40815f5c25c3de..2bd16c2de98b1b4b27a078f66d9711ebbe720706 100644 (file)
@@ -24,7 +24,7 @@ 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 of type 'str'")
+        raise TypeError(f"Parameter string[]='{type(string)}' is not of type 'str'")
 
     # Strip string
     string = string.strip()
@@ -36,7 +36,7 @@ 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 of type 'str'")
+        raise TypeError(f"Parameter string[]='{type(string)}' is not of type 'str'")
     elif string == "":
         raise ValueError("Parameter 'string' is empty")
 
index f4da98d3506734ed4182c6143ce94ec7575039b6..a9102f19d9bcf82c1bf754f5b26e2a436eda2691 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 is invoked")
     elif not isinstance(headers, dict):
-        raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'")
+        raise TypeError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'")
 
     # Default headers with no CSRF
     reqheaders = headers
index 5954ae73257b88573d99f1a877628cffeed13e48..6349b7f64dc113a5d69850d4ee4bb6cdf9b13060 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 ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
+        raise TypeError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
     elif not isinstance(command, str):
-        raise ValueError(f"Parameter command[]='{type(command)}' is not of type 'str'")
+        raise TypeError(f"Parameter command[]='{type(command)}' is not of type 'str'")
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
     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 ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of 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 ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
 
     # Increase depth
     _DEPTH = _DEPTH + 1
@@ -227,13 +227,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 ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
     elif isinstance(software, str) and software == "":
         raise ValueError("Parameter 'software' is empty")
     elif software is not None and software_helper.is_relay(software):
         raise ValueError(f"domain='{domain}' is of software='{software}' and isn't supported here.")
     elif not isinstance(origin, str) and origin is not None:
-        raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
+        raise TypeError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
     elif isinstance(origin, str) and origin == "":
         raise ValueError("Parameter 'origin' is empty")
 
@@ -295,7 +295,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 ValueError(f"path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is empty")
     elif not path.startswith("/"):
@@ -398,7 +398,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 ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of type 'str'")
     elif path is not None and not path.startswith("/"):
         raise ValueError(f"path='{path}' does not start with a slash")
 
@@ -489,13 +489,13 @@ def find_domains(tag: bs4.element.Tag, domain_column: str = "dt", reason_column:
     logger.debug("tag[]='%s',domain_column='%s',reason_column='%s',reason_text='%s' - CALLED!", type(tag), domain_column, reason_column, reason_text)
 
     if not isinstance(tag, bs4.element.Tag):
-        raise ValueError(f"Parameter tag[]='{type(tag)}' is not type of bs4.element.Tag")
+        raise TypeError(f"Parameter tag[]='{type(tag)}' is not type of bs4.element.Tag")
     elif not isinstance(domain_column, str):
-        raise ValueError(f"Parameter domain_column[]='{type(domain_column)}' is not type of 'str'")
+        raise TypeError(f"Parameter domain_column[]='{type(domain_column)}' is not type of 'str'")
     elif domain_column == "":
         raise ValueError("Parameter 'domain_column' is an empty string")
     elif not isinstance(reason_column, str):
-        raise ValueError(f"Parameter reason_column[]='{type(reason_column)}' is not type of 'str'")
+        raise TypeError(f"Parameter reason_column[]='{type(reason_column)}' is not type of 'str'")
     elif reason_column == "":
         raise ValueError("Parameter 'reason_column' is an empty string")
     elif len(tag.find_all(domain_column)) == 0:
@@ -503,7 +503,7 @@ def find_domains(tag: bs4.element.Tag, domain_column: str = "dt", reason_column:
     elif len(tag.find_all(reason_column)) == 0:
         raise KeyError("No reason_column='{reason_column}' rows found in table!")
     elif not isinstance(reason_text, str):
-        raise ValueError(f"Parameter reason_text[]='{type(reason_text)}' is not type of 'str'")
+        raise TypeError(f"Parameter reason_text[]='{type(reason_text)}' is not type of 'str'")
     elif reason_text == "":
         raise ValueError("Parameter 'reason_text' is an empty string")
 
@@ -559,7 +559,7 @@ 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 of type 'dict'")
+        raise TypeError(f"Parameter rows[]='{type(rows)}' is not of type 'dict'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is empty")
 
index 97d3cfa1e7ef74746d575066e0623227be4e388a..8a3bd67b5eab4914c8f6d72be58f95facfd00ff8 100644 (file)
@@ -72,13 +72,13 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = {}) ->
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of 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 ValueError(f"data[]='{type(data)}' is not of type 'str'")
+        raise TypeError(f"data[]='{type(data)}' is not of type 'str'")
     elif headers is not None and not isinstance(headers, dict):
         raise ValueError(f"headers[]='{type(headers)}' is not of type 'dict'")
 
@@ -132,13 +132,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 ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is empty")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(timeout, tuple):
-        raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
 
     json_reply = {
        "status_code": 200,
@@ -176,15 +176,15 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict:
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of 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 ValueError(f"headers[]='{type(headers)}' is not of type 'list'")
+        raise TypeError(f"headers[]='{type(headers)}' is not of type 'list'")
     elif not isinstance(timeout, tuple):
-        raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
 
     json_reply = {
         "status_code": 200,
@@ -235,7 +235,7 @@ def send_bot_post(domain: str, blocklist: list) -> None:
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(blocklist, list):
-        raise ValueError(f"Parameter blocklist[]='{type(blocklist)}' is not of type 'list'")
+        raise TypeError(f"Parameter blocklist[]='{type(blocklist)}' is not of type 'list'")
     elif len(blocklist) == 0:
         raise ValueError("Parameter 'blocklist' is empty")
     elif config.get("bot_token") == "":
@@ -287,17 +287,17 @@ def _fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of 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 ValueError(f"headers[]='{type(headers)}' is not of type 'dict'")
+        raise TypeError(f"headers[]='{type(headers)}' is not of type 'dict'")
     elif not isinstance(timeout, tuple):
-        raise ValueError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
+        raise TypeError(f"timeout[]='{type(timeout)}' is not of type 'tuple'")
     elif not isinstance(allow_redirects, bool):
-        raise ValueError(f"allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
+        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
 
     start = 0
     try:
@@ -334,17 +334,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 ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is empty")
     elif not validators.url(url):
         raise ValueError(f"Parameter url='{url}' is not a valid URL")
     elif not isinstance(headers, dict):
-        raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'")
+        raise TypeError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'")
     elif not isinstance(timeout, tuple):
-        raise ValueError(f"Parameter timeout[]='{type(timeout)}' is not of type 'tuple'")
+        raise TypeError(f"Parameter timeout[]='{type(timeout)}' is not of type 'tuple'")
     elif not isinstance(allow_redirects, bool):
-        raise ValueError(f"Parameter allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
+        raise TypeError(f"Parameter allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
 
     logger.debug("Parsing url='%s' ...", url)
     components = urlparse(url)
@@ -377,13 +377,13 @@ 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 ValueError(f"hostname[]='{type(hostname)}' is not of type 'str'")
+        raise TypeError(f"hostname[]='{type(hostname)}' is not of 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 ValueError(f"path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of type 'str'")
     elif path == "":
         raise ValueError("Parameter 'path' is an empty string")
     elif not path.startswith("/"):
@@ -391,7 +391,7 @@ def fetch_json_rows(hostname: str, path: str, headers: dict = {}, rows_key: str
     elif headers is not None and not isinstance(headers, dict):
         raise ValueError(f"headers[]='{type(headers)}' is not of type 'dict'")
     elif not isinstance(rows_key, str) and rows_key is not None:
-        raise ValueError(f"rows_key[]='{type(rows_key)}' is not of type 'str'")
+        raise TypeError(f"rows_key[]='{type(rows_key)}' is not of type 'str'")
     elif rows_key is not None and rows_key == "":
         raise ValueError("Parameter 'rows_key' is an empty string")
 
@@ -431,13 +431,13 @@ def get_generic(domain: str, path: str, allow_redirects: bool = False) -> reques
     if blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(path, str):
-        raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of 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(allow_redirects, bool):
-        raise ValueError(f"allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
+        raise TypeError(f"allow_redirects[]='{type(allow_redirects)}' is not of type 'bool'")
 
     logger.debug("Fetching path='%s' from domain='%s' ...", path, domain)
     response = _fetch_response(
index 1fad0e5a38371cea53bdfeba7564fa6d78ba0eac..59259b2b563b796d7ef78db4af0b7411fb8d834a 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 ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"Parameter path[]='{type(path)}' is not of 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 ValueError(f"Parameter update_mode[]='{type(update_mode)}' is not of type 'bool'")
+        raise TypeError(f"Parameter update_mode[]='{type(update_mode)}' is not of type 'bool'")
 
     if path is None and update_mode:
         logger.debug("Fetching well-known nodeinfo from domain='%s' ...", domain)
index 37ab31dfd1de4c47fba0fa989d99ac0c17a13ec3..ee71d4c815923cd982140776e9155ab55818436e 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 ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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", "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 ValueError(f"Parameter reason[]='{type(reason)}' is not of type 'str'")
+        raise TypError(f"Parameter reason[]='{type(reason)}' is not of type 'str'")
     elif not isinstance(block_level, str):
-        raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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", "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 ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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", "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 ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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", "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 ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
+        raise TypeError(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", "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 ValueError(f"Parameter value[]='{type(value)}' is not of type 'str'")
+        raise TypeError(f"Parameter value[]='{type(value)}' is not of type 'str'")
     elif value == "":
         raise ValueError("Parameter 'value' is empty")
     elif not isinstance(column, str):
-        raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is empty")
 
@@ -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 ValueError(f"rows[]='{type(rows)}' is not of type 'list'")
+        raise TypeError(f"rows[]='{type(rows)}' is not of type 'list'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is an empty list")
     elif not isinstance(column, str):
-        raise ValueError(f"column='{type(column)}' is not of type 'str'")
+        raise TypeError(f"column='{type(column)}' is not of type 'str'")
     elif column not in ["blocker", "blocked"]:
         raise ValueError(f"column='{column}' is not supported")
 
index 3027042e4f0d9b54c5edc740997be0be366b2b8e..61b8e287973ab857ea13325ff354225d9772a05d 100644 (file)
@@ -89,7 +89,7 @@ def _set_data(key: str, domain: str, value: any) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(key, str):
-        raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
+        raise TypeError(f"Parameter key[]='{type(key)}' is not of type 'str'")
     elif key == "":
         raise ValueError("Parameter 'key' is empty")
     elif not key in _pending:
@@ -186,21 +186,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 ValueError(f"origin[]='{type(origin)}' is not of type 'str'")
+        raise TypeError(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 of type 'str'")
+        raise TypeError(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 of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of 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 ValueError(f"software[]='{type(software)}' is not of type 'str'")
+        raise TypeError(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], rfc_2782=True):
@@ -282,7 +282,7 @@ def set_last_error(domain: str, error: any) -> None:
         _set_data("last_status_code"  , domain, error.status_code)
         _set_data("last_error_details", domain, error.reason if error.reason != "" else None)
     elif not isinstance(error, dict):
-        raise KeyError(f"Cannot handle keys in error[{type(error)}]='{error}'")
+        raise TypeError(f"Cannot handle keys in error[{type(error)}]='{error}'")
     elif "status_code" in error and "error_message" in error:
         logger.debug("Setting last_error_details='%s' (error_message)", error['error_message'])
         _set_data("last_status_code"  , domain, error["status_code"])
@@ -327,7 +327,7 @@ def is_registered(domain: str, skip_raise: bool = False) -> bool:
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
     elif not isinstance(skip_raise, bool):
-        raise ValueError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'")
+        raise TypeError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'")
 
     if not skip_raise:
         domain_helper.raise_on(domain)
@@ -351,7 +351,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 of type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of type 'str'")
     elif not column.startswith("last_"):
         raise ValueError(f"Parameter column='{column}' is not expected")
     elif blacklist.is_blacklisted(domain):
@@ -383,17 +383,17 @@ 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 ValueError(f"Parameter char[]='{type(char)}' is not of type 'str'")
+        raise TypeError(f"Parameter char[]='{type(char)}' is not of type 'str'")
     elif char == "":
         raise ValueError("Parameter 'char' is empty")
     elif not isinstance(domain, str):
-        raise ValueError(f"Parameter domain[]='{type(domain)}'")
+        raise TypeError(f"Parameter domain[]='{type(domain)}'")
     elif domain == "":
         raise ValueError("Parameter 'domain' 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 of type 'str'")
+        raise TypeError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not of type 'str'")
 
     # Init variables
     row = None
@@ -445,7 +445,7 @@ def set_last_response_time(domain: str, response_time: float) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(response_time, float):
-        raise ValueError(f"response_time[]='{type(response_time)}' is not of type 'float'")
+        raise TypeError(f"response_time[]='{type(response_time)}' is not of type 'float'")
     elif response_time < 0:
         raise ValueError(f"response_time={response_time} is below zero")
 
@@ -458,7 +458,7 @@ def set_last_requested_path(domain: str, path: float) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(path, str):
-        raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
+        raise TypeError(f"path[]='{type(path)}' is not of type 'str'")
     elif path == "":
         raise ValueError(f"path='{path}' is an empty string")
     elif not path.startswith("/"):
@@ -473,7 +473,7 @@ def set_total_peers(domain: str, peers: list) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(peers, list):
-        raise ValueError(f"Parameter peers[]='{type(peers)}' is not of type 'list'")
+        raise TypeError(f"Parameter peers[]='{type(peers)}' is not of type 'list'")
 
     # Set timestamp
     _set_data("total_peers", domain, len(peers))
@@ -484,7 +484,7 @@ def set_total_blocks(domain: str, blocks: list) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(blocks, list):
-        raise ValueError(f"Parameter blocks[]='{type(blocks)}' is not of type 'list'")
+        raise TypeError(f"Parameter blocks[]='{type(blocks)}' is not of type 'list'")
 
     # Set timestamp
     _set_data("total_blocks", domain, len(blocks))
@@ -495,7 +495,7 @@ def set_obfuscated_blocks(domain: str, obfuscated: int) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(obfuscated, int):
-        raise ValueError(f"Parameter obfuscated[]='{type(obfuscated)}' is not of type 'int'")
+        raise TypeError(f"Parameter obfuscated[]='{type(obfuscated)}' is not of type 'int'")
     elif obfuscated < 0:
         raise ValueError(f"Parameter obfuscated={obfuscated} is not valid")
 
@@ -508,7 +508,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 ValueError(f"Parameter url[]='{type(url)}' is not of type 'str'")
+        raise TypeError(f"Parameter url[]='{type(url)}' is not of type 'str'")
     elif url == "":
         raise ValueError("Parameter 'url' is empty")
     elif url is not None and not validators.url(url):
@@ -523,7 +523,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 ValueError(f"Parameter mode[]='{type(mode)}' is not of type 'str'")
+        raise TypeError(f"Parameter mode[]='{type(mode)}' is not of type 'str'")
     elif mode == "":
         raise ValueError("Parameter 'mode' is empty")
 
@@ -536,7 +536,7 @@ def set_has_obfuscation(domain: str, has_obfuscation: bool) -> None:
     domain_helper.raise_on(domain)
 
     if not isinstance(has_obfuscation, bool):
-        raise ValueError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' is not of type 'bool'")
+        raise TypeError(f"Parameter has_obfuscation[]='{type(has_obfuscation)}' is not of type 'bool'")
 
     # Set timestamp
     _set_data("has_obfuscation", domain, has_obfuscation)
@@ -547,7 +547,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 ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
 
@@ -560,7 +560,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 ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+        raise TypeError(f"Parameter software[]='{type(software)}' is not of type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is empty")
 
@@ -572,11 +572,11 @@ def valid(value: str, column: str) -> bool:
     logger.debug("value='%s',column='%s' - CALLED!", value, column)
 
     if not isinstance(value, str):
-        raise ValueError(f"Parameter value[]='{type(value)}' is not of type 'str'")
+        raise TypeError(f"Parameter value[]='{type(value)}' is not of type 'str'")
     elif value == "":
         raise ValueError("Parameter 'value' is empty")
     elif not isinstance(column, str):
-        raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is empty")
 
@@ -594,7 +594,7 @@ def delete(search: str, column: str = "domain") -> None:
     logger.debug("search='%s, column='%s'' - CALLED!", search, column)
 
     if not isinstance(column, str):
-        raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'")
+        raise TypeError(f"Parameter column[]='{type(column)}' is not of type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is empty")
     elif column in ["domain", "origin"]:
@@ -611,11 +611,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 ValueError("rows[]='{type(rows)}' is not of type 'list'")
+        raise TypeError("rows[]='{type(rows)}' is not of type 'list'")
     elif len(rows) == 0:
         raise ValueError("Parameter 'rows' is an empty list")
     elif not isinstance(column, str):
-        raise ValueError(f"column='{type(column)}' is not of type 'str'")
+        raise TypeError(f"column='{type(column)}' is not of type 'str'")
     elif column == "":
         raise ValueError("Parameter 'column' is empty")
     elif column not in ["domain", "origin"]:
index 75f9deec4d081839d9c509954d3d1d63cf2fa340..e9dc6605cc0d0a604224b7dadae1747f69e3ad98 100644 (file)
@@ -26,8 +26,9 @@ logger = logging.getLogger(__name__)
 
 def has(pattern: str) -> bool:
     logger.debug("pattern='%s' - CALLED!", pattern)
+
     if not isinstance(pattern, str):
-        raise ValueError(f"pattern[]='{type(pattern)}' is not of type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
 
@@ -43,8 +44,9 @@ def has(pattern: str) -> bool:
 
 def add(pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
+
     if not isinstance(pattern, str):
-        raise ValueError(f"pattern[]='{type(pattern)}' is not of type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif has(pattern):
@@ -59,8 +61,9 @@ def add(pattern: str) -> None:
 
 def update (pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
+
     if not isinstance(pattern, str):
-        raise ValueError(f"pattern[]='{type(pattern)}' is not of type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif not has(pattern):
@@ -75,8 +78,9 @@ def update (pattern: str) -> None:
 
 def delete (pattern: str) -> None:
     logger.debug("pattern='%s' - CALLED!", pattern)
+
     if not isinstance(pattern, str):
-        raise ValueError(f"pattern[]='{type(pattern)}' is not of type 'str'")
+        raise TypeError(f"pattern[]='{type(pattern)}' is not of type 'str'")
     elif pattern == "":
         raise ValueError("Parametern 'pattern' is an empty string")
     elif not has(pattern):
index 5dcbdd510ca265d6b72848e0fb3184cef38d0ac3..7ecd7d068f36acb62c1231d053be4db7a59e7ec0 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 ValueError(f"Parameter doc[]='{type(only)}' is not of type 'bs4.BeautifulSoup'")
+        raise TypeError(f"Parameter doc[]='{type(only)}' is not of type 'bs4.BeautifulSoup'")
     elif not isinstance(only, str) and only is not None:
-        raise ValueError(f"Parameter only[]='{type(only)}' is not of type 'str'")
+        raise TypeError(f"Parameter only[]='{type(only)}' is not of type 'str'")
     elif isinstance(only, str) and only == "":
         raise ValueError("Parameter 'only' is empty")
 
index 39295f3713237ee2abfef52e67e5122c961bb0be..2ef3de68ca4119849b57624e7b9ea1468c59f929 100644 (file)
@@ -46,9 +46,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 ValueError(f"Parameter tags[]='{type(tags)}' is not of type 'ResultSet'")
+        raise TypeError(f"Parameter tags[]='{type(tags)}' is not of type 'ResultSet'")
     elif not isinstance(search, str):
-        raise ValueError(f"Parameter search[]='{type(search)}' is not of type 'str'")
+        raise TypeError(f"Parameter search[]='{type(search)}' is not of type 'str'")
     elif search == "":
         raise ValueError("Parameter 'search' is empty")
 
@@ -90,7 +90,7 @@ def deobfuscate(domain: str, blocker: str, domain_hash: str = None) -> str:
     if validators.domain(domain, rfc_2782=True) and blacklist.is_blacklisted(domain):
         raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
     elif not isinstance(domain_hash, str) and domain_hash is not None:
-        raise ValueError(f"Parameter domain_hash[]='{type(domain_hash)}' is not of type 'str'")
+        raise TypeError(f"Parameter domain_hash[]='{type(domain_hash)}' is not of type 'str'")
     elif domain_hash == "":
         raise ValueError("Parameter 'domain_hash' is empty")