From 2d9f67a2df96a2490683fa62a1c3589d81aef8ed Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 18 Apr 2023 16:37:30 +0300 Subject: [PATCH] Updated for repo name --- slpkg/binaries/required.py | 2 +- slpkg/downloader.py | 24 ++++++++++++++---------- slpkg/upgrade.py | 2 +- slpkg/utilities.py | 2 +- slpkg/views/views.py | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/slpkg/binaries/required.py b/slpkg/binaries/required.py index 4b3fb3ca..c3a77253 100644 --- a/slpkg/binaries/required.py +++ b/slpkg/binaries/required.py @@ -23,7 +23,7 @@ class Required: self.repos.slint_repo_name ] - self.repo = self.utils.get_the_repo_name(self.data) + self.repo = self.utils.repository_name(self.data) def resolve(self) -> list: """ Resolve the dependencies. """ diff --git a/slpkg/downloader.py b/slpkg/downloader.py index fd9dd43a..eb378773 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +import shutil from typing import Union from pathlib import Path from urllib.parse import unquote @@ -45,17 +46,20 @@ class Downloader(Configs): command: str = '' filename: str = url.split('/')[-1] - if self.downloader in ['wget', 'wget2']: - command: str = f'{self.downloader} {self.wget_options} --directory-prefix={self.path} "{url}"' - - elif self.downloader == 'curl': - command: str = f'{self.downloader} {self.curl_options} "{url}" --output {self.path}/{filename}' - - elif self.downloader == 'lftp': - command: str = f'{self.downloader} {self.lftp_get_options} {url} -o {self.path}' - + if url.startswith('file'): + shutil.copy2(url[7:], self.tmp_slpkg) else: - self.utils.raise_error_message(f"Downloader '{self.downloader}' not supported") + if self.downloader in ['wget', 'wget2']: + command: str = f'{self.downloader} {self.wget_options} --directory-prefix={self.path} "{url}"' + + elif self.downloader == 'curl': + command: str = f'{self.downloader} {self.curl_options} "{url}" --output {self.path}/{filename}' + + elif self.downloader == 'lftp': + command: str = f'{self.downloader} {self.lftp_get_options} {url} -o {self.path}' + + else: + self.utils.raise_error_message(f"Downloader '{self.downloader}' not supported") self.utils.process(command) self.check_if_downloaded(url) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index fad0e0ce..d61e4b0e 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -25,7 +25,7 @@ class Upgrade(Configs): self.option_for_binaries: bool = self.utils.is_option( ['-B', '--bin-repo='], self.flags) - self.repo: str = self.utils.get_the_repo_name(self.data) + self.repo: str = self.utils.repository_name(self.data) logging.basicConfig(filename=str(LoggingConfig.log_file), filemode='w', diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 79c542cb..8ee2113b 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -193,7 +193,7 @@ class Utilities: if [black for black in self.black.packages() if fnmatch.fnmatch(name, black)]: return True - def get_the_repo_name(self, data): + def repository_name(self, data): """ Get the binary repository name from the repository data. """ try: # Binary repository name diff --git a/slpkg/views/views.py b/slpkg/views/views.py index eef3e961..25be5aea 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -53,7 +53,7 @@ class ViewMessage(Configs): self.option_for_binaries: bool = self.utils.is_option( ['-B', '--bin-repo='], self.flags) - self.repo: str = self.utils.get_the_repo_name(self.data) + self.repo: str = self.utils.repository_name(self.data) def view_packages(self, package: str, mode: str) -> None: """ Printing the main packages. """