]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2023 10:10:42 +0000 (12:10 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2023 10:10:42 +0000 (12:10 +0200)
- if later more "hidden" blocklists are added --domain=foo can only process
  foo's blocklist

fba/boot.py
fba/commands.py

index a2941ab9d641e8433a4494484d0aad45d8bd0945..d7dbb2f7eafadbc81b6bef246b96a625de5be544 100644 (file)
@@ -129,6 +129,7 @@ def init_parser():
         help="Fetches CSV files (block recommendations) for more possible instances to disover",
     )
     parser.set_defaults(command=commands.fetch_csv)
+    parser.add_argument("--domain", help="Instance name (aka. domain) to check")
 
     ### Fetch instances from given initial instance ###
     parser = subparser_command.add_parser(
index b88fde6e435d3da10c4dc71755f8be7e0cf861f5..f62de8032ed81471e70b3c12625ff97a5b59d27f 100644 (file)
@@ -1002,6 +1002,13 @@ def fetch_csv(args: argparse.Namespace) -> int:
     logger.info("Checking %d CSV files ...", len(blocklists.csv_files))
     for block in blocklists.csv_files:
         logger.debug("block[blocker]='%s',block[csv_url]='%s'", block["blocker"], block["csv_url"])
+
+        # Is domain given and not equal blocker?
+        if isinstance(args.domain, str) and args.domain != block["blocker"]:
+            logger.debug("Skipping blocker='%s', not matching args.domain='%s'", block["blocker"], args.domain)
+            continue
+
+        logger.debug("Invoking processing.csv_block(%s, %s, fetch_csv) ...", block["blocker"], block["csv_url"])
         processing.csv_block(block["blocker"], block["csv_url"], inspect.currentframe().f_code.co_name)
 
     logger.debug("Success - EXIT!")
@@ -1031,7 +1038,10 @@ def fetch_oliphant(args: argparse.Namespace) -> int:
             logger.debug("Skipping blocker='%s', not matching args.domain='%s'", block["blocker"], args.domain)
             continue
 
-        processing.csv_block(block["blocker"], f"{base_url}/{block['csv_url']}", inspect.currentframe().f_code.co_name)
+        url = f"{base_url}/{block['csv_url']}"
+
+        logger.debug("Invoking processing.csv_block(%s, %s, fetch_oliphant) ...", block["blocker"], url)
+        processing.csv_block(block["blocker"], url, inspect.currentframe().f_code.co_name)
 
     logger.debug("Success! - EXIT!")
     return 0