diff --git a/proxy_scraper_checker/__main__.py b/proxy_scraper_checker/__main__.py index 5d0396a..b97f0af 100644 --- a/proxy_scraper_checker/__main__.py +++ b/proxy_scraper_checker/__main__.py @@ -8,6 +8,8 @@ import rich.traceback from rich.console import Console from rich.logging import RichHandler +from .proxy_scraper_checker import ProxyScraperChecker + def install_uvloop() -> None: if sys.implementation.name == "cpython" and sys.platform in { @@ -22,24 +24,28 @@ def install_uvloop() -> None: uvloop.install() -def setup_logging(console: Console) -> None: +def configure_logging(console: Console) -> None: rich.traceback.install(console=console) logging.basicConfig( level=logging.INFO, format="%(message)s", - handlers=[ - RichHandler(console=console, show_path=False, rich_tracebacks=True) - ], + handlers=( + RichHandler( + console=console, show_path=False, rich_tracebacks=True + ), + ), ) -if __name__ == "__main__": +def main() -> None: install_uvloop() console = Console() - setup_logging(console) - - from .proxy_scraper_checker import ProxyScraperChecker + configure_logging(console) psc = ProxyScraperChecker.from_ini("config.ini", console=console) asyncio.run(psc.run()) + + +if __name__ == "__main__": + main() diff --git a/proxy_scraper_checker/proxy_scraper_checker.py b/proxy_scraper_checker/proxy_scraper_checker.py index 2c97018..ce11e4c 100644 --- a/proxy_scraper_checker/proxy_scraper_checker.py +++ b/proxy_scraper_checker/proxy_scraper_checker.py @@ -200,7 +200,7 @@ class ProxyScraperChecker: status = response.status text = await response.text() except Exception as e: - logger.error("%s | %s | %s", source, e.__class__.__name__, e) + logger.error("%s | %s | %s", source, e.__class__.__qualname__, e) else: proxies = tuple(self.regex.finditer(text)) if proxies: @@ -335,9 +335,9 @@ class ProxyScraperChecker: for proto, proxies in self.proxies.items(): working = len(proxies) total = self.proxies_count[proto] - percentage = working / total * 100 if total else 0 + percentage = working / total if total else 0 table.add_row( - proto.upper(), f"{working} ({percentage:.1f}%)", str(total) + proto.upper(), f"{working} ({percentage:.1%})", str(total) ) return table