]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 12 Jul 2025 21:06:09 +0000 (23:06 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 12 Jul 2025 21:06:09 +0000 (23:06 +0200)
- added a few debug lines
- no need for `elif` when that block isn't exiting the function
- let's use our own functions instead of checking `foo in bar`

fba/helpers/config.py
fba/helpers/cookies.py
fba/helpers/domain.py
fba/helpers/software.py

index 6788182e593ab6537fd81817b9d6a268b18a5b80..e4fa73f39358d953e97f51fec1a78c41ad7c176a 100644 (file)
@@ -30,7 +30,7 @@ logging.basicConfig(level=logging.INFO)
 logger = logging.getLogger(__name__)
 #logger.setLevel(logging.DEBUG)
 
-with open("config.json", 'r', encoding='utf-8') as f:
+with open("config.json", "r", encoding="utf-8") as f:
     logger.debug("Loading configuration file ...")
     _config = json.loads(f.read())
     _config["max_crawl_depth"] = min(_config["max_crawl_depth"], (sys.getrecursionlimit() - 50))
index 253ccc6947fec42a0c4f5a8033ce432549d60c6f..f768d9ea95662660e95e811492050cd92f2e149a 100644 (file)
@@ -35,6 +35,7 @@ def store(domain: str, cookies: dict):
     elif not isinstance(cookies, dict):
         raise TypeError(f"Parameter cookies[]='{type(cookies)}' has not expected type 'dict'")
 
+    logger.debug("Setting %d cookie(s) for domain='%s'", len(cookies), domain)
     _cookies[domain] = cookies
 
     logger.debug("EXIT!")
@@ -45,7 +46,8 @@ def get_all(domain: str) -> dict:
 
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
-    elif domain not in _cookies:
+    elif not has(domain):
+        logger.debug("domain='%s' has no cookies set, returning empty dict - EXIT!", domain)
         return []
 
     logger.debug("_cookies[%s]()=%d - EXIT!", domain, len(_cookies[domain]))
index 6d9130354a7a70eb84bd98f4432af24b3b80d90b..ec3da8d1ef2c2f35ed462616221fddd857cfd7dc 100644 (file)
@@ -146,6 +146,7 @@ def encode_idna(domain: str) -> str:
     logger.debug("domain='%s' - CALLED!", domain)
     raise_on(domain)
 
+    logger.debug("domain='%s' - BEFORE!", domain)
     punycode = domain.lstrip(".").split("?")[0]
     logger.debug("punycode='%s' - AFTER!", punycode)
 
index 10a1cf215bc35d97457e1c9b122570339198fc43..f84476c36c0f29eedf27c85ee518e84db9910f13 100644 (file)
@@ -114,7 +114,8 @@ def alias(software: str) -> str:
         raise TypeError(f"software[]='{type(software)}' is not type 'str'")
     elif software == "":
         raise ValueError("Parameter 'software' is an empty string")
-    elif software.startswith("re:"):
+
+    if software.startswith("re:"):
         logger.debug("Cutting prefix 're:' from software='%s' ...", software)
         software = software.split(":")[1]