From 828a7eaefd30aa0bad5c95cfe2f89c1c25f945e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 12 Jul 2025 23:06:09 +0200 Subject: [PATCH] Continued: - 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 | 2 +- fba/helpers/cookies.py | 4 +++- fba/helpers/domain.py | 1 + fba/helpers/software.py | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fba/helpers/config.py b/fba/helpers/config.py index 6788182..e4fa73f 100644 --- a/fba/helpers/config.py +++ b/fba/helpers/config.py @@ -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)) diff --git a/fba/helpers/cookies.py b/fba/helpers/cookies.py index 253ccc6..f768d9e 100644 --- a/fba/helpers/cookies.py +++ b/fba/helpers/cookies.py @@ -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])) diff --git a/fba/helpers/domain.py b/fba/helpers/domain.py index 6d91303..ec3da8d 100644 --- a/fba/helpers/domain.py +++ b/fba/helpers/domain.py @@ -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) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index 10a1cf2..f84476c 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -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] -- 2.39.5