From faa5f3e0194988ea110ff3243a5955b1c2fee5b9 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 25 Mar 2023 19:48:02 +0200 Subject: [PATCH] Merge method from utils --- slpkg/update_repository.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 6a932d15..b29b237b 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -70,9 +70,9 @@ class UpdateRepository(Configs): urls.append(f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}') urls.append(f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_checksums}') - self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_packages) - self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) - self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums) + self.utils.remove_file_if_exists(self.repos.gnome_repo_path, self.repos.gnome_repo_packages) + self.utils.remove_file_if_exists(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog) + self.utils.remove_file_if_exists(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums) down = Downloader(self.repos.gnome_repo_path, urls, self.flags) down.download() @@ -94,9 +94,9 @@ class UpdateRepository(Configs): urls.append(f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}') urls.append(f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_checksums}') - self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_packages) - self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) - self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums) + self.utils.remove_file_if_exists(self.repos.conraid_repo_path, self.repos.conraid_repo_packages) + self.utils.remove_file_if_exists(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog) + self.utils.remove_file_if_exists(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums) down = Downloader(self.repos.conraid_repo_path, urls, self.flags) down.download() @@ -114,7 +114,7 @@ class UpdateRepository(Configs): print('Updating the packages list...\n') print(f"Downloading the '{self.green}{self.repos.ponce_repo_name}" f"{self.endc}' repository, please wait...\n") - self.delete_file(self.repos.ponce_repo_path, self.repos .ponce_repo_slackbuilds) + self.utils.remove_file_if_exists(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds) lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.ponce_repo_mirror} ' f'{self.repos.ponce_repo_path}') self.utils.process(lftp_command) @@ -135,8 +135,8 @@ class UpdateRepository(Configs): self.make_dirs(self.repos.sbo_repo_name) print('Updating the packages list...\n') - self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds) - self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog) + self.utils.remove_file_if_exists(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds) + self.utils.remove_file_if_exists(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog) print(f"Downloading the '{self.green}{self.repos.sbo_repo_name}{self.endc}' repository, please wait...\n") lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_mirror} ' @@ -197,13 +197,6 @@ class UpdateRepository(Configs): self.update = queue.get() self.update_the_repositories() - @staticmethod - def delete_file(folder: Path, txt_file: str) -> None: - """ Delete the file. """ - file = Path(folder, txt_file) - if file.exists(): - file.unlink() - def delete_sbo_data(self) -> None: """ Delete all the data from a table of the database. """ if self.repos.ponce_repo: