From 3eedaf77e21790a1b1f395a3c4017e3e52758521 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:18:24 -0500 Subject: [PATCH] Allow `src/utils/__init__.py` to be empty --- src/__main__.py | 32 +++++++++++++++----------------- src/utils/__init__.py | 3 --- src/utils/upload.py | 1 - 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index fd6211f..1771e84 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,9 +1,7 @@ # To run from the root project directory, run the following command: # python -m src.__main__ from loguru import logger -# Import the utils package -from . import utils -# import utils +from .utils import upload, delete, utils import argparse import os @@ -103,26 +101,26 @@ def main(): exit(1) try : args.func(args) - except AttributeError: + except AttributeError as e: + logger.debug(e) argparser.print_help() - pass def upload_to_cloudflare(args): logger.info("Uploading to Cloudflare") - blocklists = utils.upload.get_blocklists(args.blocklists) - blocklists = utils.upload.apply_whitelists(blocklists, args.whitelists) - lists = utils.upload.split_list(blocklists) - utils.upload.upload_to_cloudflare(lists, ACCOUNT_ID, TOKEN) - cloud_lists = utils.utils.get_lists(ACCOUNT_ID, TOKEN) - cloud_lists = utils.utils.filter_adblock_lists(cloud_lists) - utils.upload.create_dns_policy(cloud_lists, ACCOUNT_ID, TOKEN) + blocklists = upload.get_blocklists(args.blocklists) + blocklists = upload.apply_whitelists(blocklists, args.whitelists) + lists = upload.split_list(blocklists) + upload.upload_to_cloudflare(lists, ACCOUNT_ID, TOKEN) + cloud_lists = utils.get_lists(ACCOUNT_ID, TOKEN) + cloud_lists = utils.filter_adblock_lists(cloud_lists) + upload.create_dns_policy(cloud_lists, ACCOUNT_ID, TOKEN) def delete_from_cloudflare(args): logger.info("Deleting from Cloudflare") - rules = utils.utils.get_gateway_rules(ACCOUNT_ID, TOKEN) - utils.delete.delete_adblock_policy(rules, ACCOUNT_ID, TOKEN) - lists = utils.utils.get_lists(ACCOUNT_ID, TOKEN) - lists = utils.utils.filter_adblock_lists(lists) - utils.delete.delete_adblock_list(lists, ACCOUNT_ID, TOKEN) + rules = utils.get_gateway_rules(ACCOUNT_ID, TOKEN) + delete.delete_adblock_policy(rules, ACCOUNT_ID, TOKEN) + lists = utils.get_lists(ACCOUNT_ID, TOKEN) + lists = utils.filter_adblock_lists(lists) + delete.delete_adblock_list(lists, ACCOUNT_ID, TOKEN) if __name__ == "__main__": main() diff --git a/src/utils/__init__.py b/src/utils/__init__.py index ed1e77e..e69de29 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,3 +0,0 @@ -from .utils import * -from .upload import * -from .delete import * diff --git a/src/utils/upload.py b/src/utils/upload.py index 8f05c19..51c184a 100644 --- a/src/utils/upload.py +++ b/src/utils/upload.py @@ -98,6 +98,5 @@ def main(): cloud_lists = utils.filter_adblock_lists(cloud_lists) create_dns_policy(cloud_lists) - if __name__ == "__main__": main()