Skip to content

Commit

Permalink
🎨 Apply automatic code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jh0ker committed Feb 5, 2025
1 parent b41ccd2 commit 2f16b18
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import importlib
import json
import os
from pathlib import Path
import sys
from typing import Optional, Tuple
import shutil
import sys
from pathlib import Path

import click
from copier import Worker, DEFAULT_DATA
import yaml

from copier import DEFAULT_DATA, Worker

BASE_DIR = Path(__file__).parent
TEMPLATE_NAME = "scraper_template"
Expand All @@ -25,8 +23,8 @@ def _success(
text: str,
*,
nl: bool = True,
echo_kwargs: Optional[dict] = None,
style_kwargs: Optional[dict] = None,
echo_kwargs: dict | None = None,
style_kwargs: dict | None = None,
):
click.echo(
click.style(text, fg="green", bold=True, **(style_kwargs or {})),
Expand All @@ -39,8 +37,8 @@ def _warn(
text: str,
*,
nl: bool = True,
echo_kwargs: Optional[dict] = None,
style_kwargs: Optional[dict] = None,
echo_kwargs: dict | None = None,
style_kwargs: dict | None = None,
):
click.echo(
click.style(text, fg="yellow", bold=True, **(style_kwargs or {})),
Expand All @@ -53,8 +51,8 @@ def _error(
text: str,
*,
nl: bool = True,
echo_kwargs: Optional[dict] = None,
style_kwargs: Optional[dict] = None,
echo_kwargs: dict | None = None,
style_kwargs: dict | None = None,
):
click.echo(
click.style(text, fg="red", bold=True, **(style_kwargs or {})), nl=nl, **(echo_kwargs or {})
Expand All @@ -65,8 +63,8 @@ def _info(
text: str,
*,
nl: bool = True,
echo_kwargs: Optional[dict] = None,
style_kwargs: Optional[dict] = None,
echo_kwargs: dict | None = None,
style_kwargs: dict | None = None,
):
click.echo(
click.style(text, fg="bright_blue", **(style_kwargs or {})), nl=nl, **(echo_kwargs or {})
Expand All @@ -88,17 +86,17 @@ def _save_scrapers_config(scrapers_config: list[dict]):
json.dump(scrapers_config, fp, indent=4, ensure_ascii=False)


def _find_scraper_by_name(name: str, scraper_config: list[dict]) -> Optional[dict]:
def _find_scraper_by_name(name: str, scraper_config: list[dict]) -> dict | None:
by_display_name = {entry["display_name"]: entry for entry in scraper_config}
by_module_name = {entry["module_name"]: entry for entry in scraper_config}
return by_display_name.get(name) or by_module_name.get(name)


def _delete_scraper(scraper: dict, scrapers_config) -> Tuple[bool, list[dict]]:
def _delete_scraper(scraper: dict, scrapers_config) -> tuple[bool, list[dict]]:
_warn(f"Warning: This will delete all files at {SCRAPERS_DIR / scraper['module_name']}")
_info("To continue, please type ", nl=False)
click.echo(click.style("DELETE", fg="bright_red", bold=True), nl=False)
if "DELETE" != click.prompt("", default="", show_default=False):
if click.prompt("", default="", show_default=False) != "DELETE":
_warn("Aborting!")
return False, scrapers_config

Expand Down Expand Up @@ -265,7 +263,7 @@ def test_scraper(module_name):
else:
_warn("Warning: Scraper has no run() method")

except Exception as e:
except Exception:
_error("Scraper failed! Logging error...\n")
raise

Expand All @@ -291,8 +289,8 @@ def test_all_scrapers():
for scraper in scrapers_config:
try:
test_scraper([scraper["module_name"]])
except:
print("")
except Exception:
print()


@cli.command("generate", help='Generate the "serverless.yml" for deployment.')
Expand Down

0 comments on commit 2f16b18

Please sign in to comment.