From 95802d1e64f43883c57c5409a28c21f3aa28a52e Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 12 May 2023 12:19:34 +0100 Subject: [PATCH] Fix regression with downloader mapper on aria2c and saldl The setup I had for using asyncio.run with functools.partial didn't actually pan out. A full pass-through lambda is required. I've also moved the mapped downloader variable to the root of the downloaders package. --- devine/core/downloaders/__init__.py | 11 ++++++++++- devine/core/downloaders/downloader.py | 12 ------------ 2 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 devine/core/downloaders/downloader.py diff --git a/devine/core/downloaders/__init__.py b/devine/core/downloaders/__init__.py index 60de9c2..8e20291 100644 --- a/devine/core/downloaders/__init__.py +++ b/devine/core/downloaders/__init__.py @@ -1,6 +1,15 @@ +import asyncio + from .aria2c import aria2c from .requests import requests from .saldl import saldl -from .downloader import downloader +from ..config import config + +downloader = { + "aria2c": lambda *args, **kwargs: asyncio.run(aria2c(*args, **kwargs)), + "requests": requests, + "saldl": lambda *args, **kwargs: asyncio.run(saldl(*args, **kwargs)) +}[config.downloader] + __ALL__ = (downloader, aria2c, requests, saldl) diff --git a/devine/core/downloaders/downloader.py b/devine/core/downloaders/downloader.py deleted file mode 100644 index 9011d52..0000000 --- a/devine/core/downloaders/downloader.py +++ /dev/null @@ -1,12 +0,0 @@ -import asyncio -from functools import partial - -from devine.core.config import config -from devine.core.downloaders import aria2c, requests, saldl - - -downloader = { - "aria2c": partial(asyncio.run, aria2c), - "requests": requests, - "saldl": partial(asyncio.run, saldl) -}[config.downloader]