diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 9852d432..aad5cf1d 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -63,6 +63,7 @@ class BinaryInstall: self.yellow = _meta_.color['YELLOW'] self.endc = _meta_.color["ENDC"] self.msg = Msg() + self.utils = Utils() self.version = self.meta.slack_rel self.tmp_path = self.meta.slpkg_tmp_packages self.init_flags() @@ -159,10 +160,10 @@ class BinaryInstall: self.msg.template(78) if "--download-only" in self.flag: raise SystemExit() - self.dep_install = Utils().check_downloaded( - self.tmp_path, self.dep_install) - self.install = Utils().check_downloaded( - self.tmp_path, self.install) + self.dep_install = list(self.utils.check_downloaded( + self.tmp_path, self.dep_install)) + self.install = list(self.utils.check_downloaded( + self.tmp_path, self.install)) ins, upg = self.install_packages() self.msg.reference(ins, upg) write_deps(self.deps_dict) @@ -188,8 +189,8 @@ class BinaryInstall: lowercase """ if "--case-ins" in self.flag: - data = list(Utils().package_name(self.PACKAGES_TXT)) - data_dict = Utils().case_sensitive(data) + data = list(self.utils.package_name(self.PACKAGES_TXT)) + data_dict = self.utils.case_sensitive(data) for pkg in self.packages: index = self.packages.index(pkg) for key, value in data_dict.items(): @@ -200,7 +201,7 @@ class BinaryInstall: """Update dependencies dictionary with all package """ for dep in self.dependencies: - deps = Utils().dimensional_list(Dependencies( + deps = self.utils.dimensional_list(Dependencies( self.repo, self.blacklist).binary( dep, self.flag)) self.deps_dict[dep] = deps @@ -210,7 +211,7 @@ class BinaryInstall: or if added to install two or more times """ packages = [] - for mas in Utils().remove_dbs(self.packages): + for mas in self.utils.remove_dbs(self.packages): if mas not in self.dependencies: packages.append(mas) self.packages = packages @@ -264,11 +265,11 @@ class BinaryInstall: self.msg.resolving() for dep in self.packages: dependencies = [] - dependencies = Utils().dimensional_list(Dependencies( + dependencies = self.utils.dimensional_list(Dependencies( self.repo, self.blacklist).binary(dep, self.flag)) requires += list(self._fix_deps_repos(dependencies)) - self.deps_dict[dep] = Utils().remove_dbs(requires) - return Utils().remove_dbs(requires) + self.deps_dict[dep] = self.utils.remove_dbs(requires) + return self.utils.remove_dbs(requires) def _fix_deps_repos(self, dependencies): """Fix store deps include in repository diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index 01eafe38..b02861c9 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -110,8 +110,8 @@ class Patches: if self.msg.answer() in ["y", "Y"]: Download(self.patch_path, self.dwn_links, repo="slack").start() - self.upgrade_all = self.utils.check_downloaded( - self.patch_path, self.upgrade_all) + self.upgrade_all = list(self.utils.check_downloaded( + self.patch_path, self.upgrade_all)) self.upgrade() self.kernel() if self.meta.slackpkg_log in ["on", "ON"]: diff --git a/slpkg/utils.py b/slpkg/utils.py index fe4dedb1..630ac0b2 100644 --- a/slpkg/utils.py +++ b/slpkg/utils.py @@ -74,11 +74,9 @@ class Utils: """Check if files downloaded and return downloaded packages """ - downloaded = [] for pkg in maybe_downloaded: - if os.path.isfile(path + pkg): - downloaded.append(pkg) - return downloaded + if os.path.isfile(f"{path}{pkg}"): + yield pkg def read_config(self, config): """Read config file and returns first uncomment line @@ -103,7 +101,7 @@ class Utils: """Checking the file encoding default is utf-8 """ try: - with open(path + f, "r") as ftest: + with open(f"{path}{f}", "r") as ftest: ftest.read() except UnicodeDecodeError: return "ISO-8859-1" diff --git a/slpkg/version.py b/slpkg/version.py index e45b2b81..734468d7 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -22,20 +22,15 @@ # along with this program. If not, see . -from slpkg.__metadata__ import MetaData as _meta_ +from slpkg.__metadata__ import MetaData as m def prog_version(): """Print version, license and email """ - print("Version : {0}\n" - "Licence : {1}\n" - "Email : {2}\n" - "Homepage : {3}\n" - "Twitter : {4}\n" - "Maintainer: {5}".format(_meta_.__version__, - _meta_.__license__, - _meta_.__email__, - _meta_.__homepage__, - _meta_.__twitter__, - _meta_.__maintainer__)) + print(f"Version : {m.__version__}\n" + f"Licence : {m.__license__}\n" + f"Email : {m.__email__}\n" + f"Homepage : {m.__homepage__}\n" + f"Twitter : {m.__twitter__}\n" + f"Maintainer: {m.__maintainer__}")