Fixed ValueError for glob

This commit is contained in:
Dimitris Zlatanidis 2023-03-15 21:43:38 +02:00
parent 7ddd72adaa
commit e1e40b2968

View file

@ -43,21 +43,27 @@ class Utilities:
""" Return all installed packages from /val/log/packages folder. """
var_log_packages = Path(self.configs.log_packages)
for file in var_log_packages.glob(pattern):
package_name = self.split_installed_pkg(file.name)[0]
try:
for file in var_log_packages.glob(pattern):
package_name = self.split_installed_pkg(file.name)[0]
if package_name not in self.black.packages():
yield file.name
if package_name not in self.black.packages():
yield file.name
except ValueError:
pass
def all_installed_names(self, pattern: str) -> Generator:
""" Return all installed packages names from /val/log/packages folder. """
var_log_packages = Path(self.configs.log_packages)
for file in var_log_packages.glob(pattern):
package_name = self.split_installed_pkg(file.name)[0]
try:
for file in var_log_packages.glob(pattern):
package_name = self.split_installed_pkg(file.name)[0]
if package_name not in self.black.packages():
yield self.split_installed_pkg(file.name)[0]
if package_name not in self.black.packages():
yield self.split_installed_pkg(file.name)[0]
except ValueError:
pass
@staticmethod
def remove_file_if_exists(path: str, file: str) -> None: