From 27ed41a39f400d01ac4cb3376f6503bc3ae1d4ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 20 Oct 2023 06:58:47 +0200 Subject: [PATCH] Continued: - software doesn't need to be aliases each round as the variable isn't assigned inside the loop - added check in software_helper.alias() if parameter 'software' is an empty string - don't attempt to alias empty software string --- fba/commands.py | 4 +++- fba/helpers/software.py | 2 ++ fba/http/federation.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index ebca01e..c047597 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -516,6 +516,9 @@ def fetch_observer(args: argparse.Namespace) -> int: logger.info("Fetching %d different table data ...", len(types)) for software in types: logger.debug("software='%s' - BEFORE!", software) + software = software_helper.alias(software) + logger.debug("software='%s' - AFTER!", software) + if args.software is not None and args.software != software: logger.debug("args.software='%s' does not match software='%s' - SKIPPED!", args.software, software) continue @@ -559,7 +562,6 @@ def fetch_observer(args: argparse.Namespace) -> int: logger.debug("domain='%s' is already registered - SKIPPED!", domain) continue - software = software_helper.alias(software) logger.info("Fetching instances for domain='%s'", domain) federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index 95a6818..29da2b6 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -34,6 +34,8 @@ def alias(software: str) -> str: if not isinstance(software, str) and software is not None: raise ValueError(f"software[]='{type(software)}' is not type 'str'") + elif software == "": + raise ValueError("Parameter 'software' is empty") logger.debug("software='%s'- BEFORE!", software) software = tidyup.domain(software) diff --git a/fba/http/federation.py b/fba/http/federation.py index 25ec633..2c50f10 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -427,7 +427,7 @@ def determine_software(domain: str, path: str = None) -> str: logger.debug("Generator for domain='%s' is: '%s'", domain, software) logger.debug("software[%s]='%s'", type(software), software) - if software is None: + if software is None or software == "": logger.debug("Returning None - EXIT!") return None -- 2.39.5