From 86d0ae5fc2c5ee6910009363b0e850e293772f02 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:48:16 +0000 Subject: [PATCH] style: format code with black and isort Format code with black and isort This commit fixes the style issues introduced in fc08c85 according to the output from Black and isort. Details: https://app.deepsource.com/gh/slashtechno/cloudflare-gateway-adblocking/transform/140ba183-64cc-487b-8647-7ec70640c747/ --- src/__main__.py | 10 ++++++---- src/utils/delete.py | 6 ++++-- src/utils/upload.py | 11 ++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index 79ab601..cf91e2c 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -2,10 +2,11 @@ # python -m src.__main__ # python -m src # also works because __main__ is the default module import argparse +import asyncio import os from pathlib import Path from sys import exit, stderr -import asyncio + import dotenv from loguru import logger @@ -31,7 +32,9 @@ def main(): # Add arguments # General arguments - argparser.add_argument('--log-level', '-l', help='Log level', default='INFO') # noqa E501 + argparser.add_argument( + "--log-level", "-l", help="Log level", default="INFO" + ) # noqa E501 # Credential arguments credential_args.add_argument( @@ -81,8 +84,6 @@ def main(): set_primary_logger(args.log_level) logger.debug(args) - - # Load variables global TOKEN global ACCOUNT_ID @@ -134,6 +135,7 @@ def delete_from_cloudflare(args): lists = utils.filter_adblock_lists(lists) asyncio.run(delete.delete_adblock_list(lists, ACCOUNT_ID, TOKEN)) + def set_primary_logger(log_level): logger.remove() # ^10 is a formatting directive to center with a padding of 10 diff --git a/src/utils/delete.py b/src/utils/delete.py index 9dd7825..e446b90 100644 --- a/src/utils/delete.py +++ b/src/utils/delete.py @@ -1,8 +1,10 @@ # This is a scriprt to undo the changes made by adblock-zerotrust.py -import requests -import httpx import asyncio + +import httpx +import requests + from . import utils diff --git a/src/utils/upload.py b/src/utils/upload.py index 1f4c092..8646c25 100644 --- a/src/utils/upload.py +++ b/src/utils/upload.py @@ -1,8 +1,8 @@ +import asyncio import pathlib -import requests -import asyncio import httpx +import requests from . import utils @@ -48,13 +48,11 @@ def split_list(blocklists): return lists -async def upload_to_cloudflare(lists, account_id: str, token: str) -> None: +async def upload_to_cloudflare(lists, account_id: str, token: str) -> None: async with httpx.AsyncClient() as client: for i, lst in enumerate(lists): list_name = f"adblock-list-{i + 1}" - url = ( - f"https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/lists" - ) + url = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/lists" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json", @@ -79,7 +77,6 @@ async def upload_to_cloudflare(lists, account_id: str, token: str) -> None: exit(1) - def create_dns_policy(lists, account_id: str, token: str) -> None: url = f"https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules" headers = {