From 738aaa416e5f9c8006f1c0f676b9d33fd9a7d056 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 8 May 2022 18:36:11 +0300 Subject: [PATCH] Updated create paths Signed-off-by: Dimitris Zlatanidis --- slpkg/init.py | 132 +++++++++++++++++--------------------------------- 1 file changed, 44 insertions(+), 88 deletions(-) diff --git a/slpkg/init.py b/slpkg/init.py index 96fae866..113f3d79 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -56,22 +56,32 @@ class Initialization(Utils): def constructing(self): """Creating the all necessary directories """ - if not os.path.exists(self.conf_path): - os.mkdir(self.conf_path) - if not os.path.exists(self.log_path): - os.mkdir(self.log_path) - if not os.path.exists(self.lib_path): - os.mkdir(self.lib_path) - if not os.path.exists(self.tmp_path): - os.mkdir(self.tmp_path) - if not os.path.exists(self.build_path): - os.makedirs(self.build_path) - if not os.path.exists(self._SOURCES): - os.makedirs(self._SOURCES) - if not os.path.exists(self.slpkg_tmp_packages): - os.makedirs(self.slpkg_tmp_packages) - if not os.path.exists(self.slpkg_tmp_patches): - os.makedirs(self.slpkg_tmp_patches) + paths_basic = [ + self.conf_path, + self.log_path, + self.lib_path, + self.tmp_path + ] + + paths_extra = [ + self.build_path, + self._SOURCES, + self.slpkg_tmp_packages, + self.slpkg_tmp_patches + ] + + self.mkdir(paths_basic) + self.mkdirs(paths_extra) + + def mkdir(self, path: list): + for p in path: + if not os.path.exists(p): + os.mkdir(p) + + def mkdirs(self, path: list): + for p in path: + if not os.path.exists(p): + os.makedirs(p) def custom(self, name): """Creating user select repository local library @@ -84,10 +94,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) PACKAGES_TXT = f"{repo}/{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = f"{repo}{md5_file}" @@ -110,10 +117,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) dirs = ["core/", "extra/", "patches/"] for d in dirs: if not os.path.exists(lib + d): @@ -155,10 +159,7 @@ class Initialization(Utils): # lst_file = "" # md5_file = "" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) SLACKBUILDS_TXT = f"{repo}{slack_ver()}/{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = "" @@ -181,10 +182,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) PACKAGES_TXT = f"{repo}{slack_ver()}/{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = f"{repo}{slack_ver()}/{md5_file}" @@ -211,10 +209,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = arch if self.meta.slack_rel == "current": @@ -244,10 +239,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "64" PACKAGES_TXT = f"{repo}slackware{ar}-{slack_ver()}/{lib_file}" @@ -274,10 +266,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) PACKAGES_TXT = f"{repo}{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = f"{repo}{md5_file}" @@ -304,10 +293,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = f"{ver}-x86_64" if self.meta.slack_rel == "current": @@ -337,10 +323,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) PACKAGES_TXT = f"{repo}{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = f"{repo}{md5_file}" @@ -365,10 +348,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if self.meta.slack_rel == "current": ver = self.meta.slack_rel PACKAGES_TXT = f"{repo}{ver}/{lib_file}" @@ -396,10 +376,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "64" version = self.meta.slacke_sub_repo[1:-1] @@ -431,10 +408,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "x86_64" PACKAGES_TXT = f"{repo}{ar}/{slack_ver()}/{lib_file}" @@ -462,10 +436,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "x86_64" PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}" @@ -491,10 +462,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) PACKAGES_TXT = f"{repo}{lib_file}" FILELIST_TXT = "" CHECKSUMS_MD5 = f"{repo}{md5_file}" @@ -521,10 +489,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "x86_64" version = self.meta.msb_sub_repo[1:-1] @@ -556,10 +521,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "x86_64" if self.meta.slack_rel == "current": @@ -590,10 +552,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "64" PACKAGES_TXT = f"{repo}{nickname}{ar}-{slack_ver()}/{lib_file}" @@ -621,10 +580,7 @@ class Initialization(Utils): # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" - if not os.path.exists(log): - os.mkdir(log) - if not os.path.exists(lib): - os.mkdir(lib) + self.mkdir([log, lib]) if arch == "x86_64": ar = "64" version = self.meta.mles_sub_repo[1:-1]