Updated for dict

This commit is contained in:
Dimitris Zlatanidis 2023-05-13 21:58:12 +03:00
parent db8f9ad2e0
commit 03872cdc91

View file

@ -25,7 +25,12 @@ class Downloader(Configs):
self.filename = None self.filename = None
self.downloader_command: str = str() self.downloader_command: str = str()
self.downloader_tools: dict = {
'wget': self.wget_downloader,
'wget2': self.wget_downloader,
'curl': self.curl_downloader,
'lftp': self.lftp_downloader
}
self.option_for_parallel: bool = self.utils.is_option( self.option_for_parallel: bool = self.utils.is_option(
['-P', '--parallel'], flags) ['-P', '--parallel'], flags)
@ -50,18 +55,11 @@ class Downloader(Configs):
path: str = urlparse(url).path path: str = urlparse(url).path
self.filename: str = unquote(Path(path).name) self.filename: str = unquote(Path(path).name)
downloader_tool: dict = {
'wget': self.wget_downloader,
'wget2': self.wget_downloader,
'curl': self.curl_downloader,
'lftp': self.lftp_downloader
}
if url.startswith('file'): if url.startswith('file'):
self.copy_local_binary_file(url) self.copy_local_binary_file(url)
else: else:
try: try:
downloader_tool[self.downloader](url) self.downloader_tools[self.downloader](url)
except KeyError: except KeyError:
self.errors.raise_error_message(f"Downloader '{self.downloader}' not supported", exit_status=1) self.errors.raise_error_message(f"Downloader '{self.downloader}' not supported", exit_status=1)