mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-13 20:01:48 +01:00
Updated for installed
This commit is contained in:
parent
0ccd91e9c6
commit
ff2b269209
1 changed files with 13 additions and 7 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
import glob
|
||||
import time
|
||||
import shutil
|
||||
import fnmatch
|
||||
|
@ -29,22 +30,27 @@ class Utilities(Configs):
|
|||
self.stdout = None
|
||||
self.prog_version = Version()
|
||||
|
||||
self.installed_packages: dict = dict(self.all_installed())
|
||||
# self.installed_packages: dict = dict(self.all_installed())
|
||||
|
||||
def is_package_installed(self, name: str) -> str:
|
||||
""" Returns the installed package binary. """
|
||||
try:
|
||||
return self.installed_packages[name]
|
||||
except KeyError:
|
||||
return ''
|
||||
installed_package: Generator = Path(self.log_packages).glob(f'{name}*')
|
||||
for installed in installed_package:
|
||||
inst_name: str = self.split_package(installed.name)['name']
|
||||
if inst_name == name:
|
||||
return installed
|
||||
return ''
|
||||
|
||||
def all_installed(self) -> tuple:
|
||||
def all_installed(self) -> dict:
|
||||
""" Return all installed packages from /val/log/packages folder. """
|
||||
installed_packages: dict = {}
|
||||
for file in self.log_packages.glob(self.file_pattern):
|
||||
name: str = self.split_package(file.name)['name']
|
||||
|
||||
if not name.startswith('.') and not self.blacklist_pattern(name):
|
||||
yield name, file.name
|
||||
installed_packages[name] = file.name
|
||||
|
||||
return installed_packages
|
||||
|
||||
@staticmethod
|
||||
def remove_file_if_exists(path: Path, file: str) -> None:
|
||||
|
|
Loading…
Reference in a new issue