Refactor class methods

This commit is contained in:
Dimitris Zlatanidis 2023-12-01 11:53:55 +02:00
parent f2daaf75cf
commit 59b798a115

View file

@ -23,10 +23,10 @@ class Downloader(Configs):
self.filename = None self.filename = None
self.downloader_command: str = '' self.downloader_command: str = ''
self.downloader_tools: dict = { self.downloader_tools: dict = {
'wget': self.wget_downloader, 'wget': self.set_wget_downloader,
'wget2': self.wget_downloader, 'wget2': self.set_wget_downloader,
'curl': self.curl_downloader, 'curl': self.set_curl_downloader,
'lftp': self.lftp_downloader 'lftp': self.set_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)
@ -78,14 +78,14 @@ class Downloader(Configs):
except FileNotFoundError as error: except FileNotFoundError as error:
self.errors.raise_error_message(f'{error}', 1) self.errors.raise_error_message(f'{error}', 1)
def wget_downloader(self, url: str, path: Path) -> None: def set_wget_downloader(self, url: str, path: Path) -> None:
self.downloader_command: str = f'{self.downloader} {self.wget_options} --directory-prefix={path} "{url}"' self.downloader_command: str = f'{self.downloader} {self.wget_options} --directory-prefix={path} "{url}"'
def curl_downloader(self, url: str, path: Path) -> None: def set_curl_downloader(self, url: str, path: Path) -> None:
self.downloader_command: str = (f'{self.downloader} {self.curl_options} "{url}" ' self.downloader_command: str = (f'{self.downloader} {self.curl_options} "{url}" '
f'--output {path}/{self.filename}') f'--output {path}/{self.filename}')
def lftp_downloader(self, url: str, path: Path) -> None: def set_lftp_downloader(self, url: str, path: Path) -> None:
self.downloader_command: str = f'{self.downloader} {self.lftp_get_options} {url} -o {path}' self.downloader_command: str = f'{self.downloader} {self.lftp_get_options} {url} -o {path}'
def check_if_downloaded(self, url: str, path: Path) -> None: def check_if_downloaded(self, url: str, path: Path) -> None: