From 78ec837fbb871f2d9c86b80add74db2dc6ddf209 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 13 Jul 2024 22:49:32 +0200 Subject: [PATCH] Continued: - annotated more functions for caching - initialized private _config "array" (dict) --- fba/helpers/blacklist.py | 2 +- fba/helpers/config.py | 4 ++++ fba/helpers/software.py | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fba/helpers/blacklist.py b/fba/helpers/blacklist.py index 7273aa0..5f41ff9 100644 --- a/fba/helpers/blacklist.py +++ b/fba/helpers/blacklist.py @@ -98,5 +98,5 @@ def is_blacklisted(domain: str) -> bool: return blacklisted def get_all() -> dict: - logger.debug("_blacklist()=%d - CALLED!", len(_blacklist)) + logger.debug("_blacklist()=%d - EXIT!", len(_blacklist)) return _blacklist diff --git a/fba/helpers/config.py b/fba/helpers/config.py index 11ad976..091b53a 100644 --- a/fba/helpers/config.py +++ b/fba/helpers/config.py @@ -21,6 +21,10 @@ import sys logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +# Private configration array, DO NOT access this directly. Please invoke +# config.get("foo") instead +_config = {} + with open("config.json") as f: logger.debug("Loading configuration file ...") _config = json.loads(f.read()) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index c9c961a..0e6d3b2 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -205,6 +205,7 @@ def alias(software: str) -> str: logger.debug("cleared[%s]='%s' - EXIT!", type(cleared), cleared) return cleared +@lru_cache def strip_hosted_on(software: str) -> str: logger.debug("software='%s' - CALLED!", software) @@ -229,6 +230,7 @@ def strip_hosted_on(software: str) -> str: logger.debug("software='%s' - EXIT!", software) return software +@lru_cache def strip_powered_by(software: str) -> str: logger.debug("software='%s' - CALLED!", software) @@ -253,6 +255,7 @@ def strip_powered_by(software: str) -> str: logger.debug("software='%s' - EXIT!", software) return software +@lru_cache def strip_until(software: str, until: str) -> str: logger.debug("software='%s',until='%s' - CALLED!", software, until) -- 2.39.5