mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-19 10:27:07 +01:00
Updated for typing
This commit is contained in:
parent
b6b9a80d64
commit
c6c222bd4f
1 changed files with 2 additions and 9 deletions
|
@ -41,7 +41,7 @@ class Utilities(Configs):
|
|||
except KeyError:
|
||||
return ''
|
||||
|
||||
def all_installed(self) -> dict:
|
||||
def all_installed(self) -> tuple:
|
||||
""" Return all installed packages from /val/log/packages folder. """
|
||||
for file in self.log_packages.glob(self.file_pattern):
|
||||
name: str = self.split_package(file.name)['name']
|
||||
|
@ -78,7 +78,7 @@ class Utilities(Configs):
|
|||
build: str = ''.join(re.findall(r'\d+', build_tag[:2]))
|
||||
pkg_tag: str = build_tag[len(build):]
|
||||
|
||||
split: dict = {
|
||||
split: dict[str] = {
|
||||
'name': name,
|
||||
'version': version,
|
||||
'arch': arch,
|
||||
|
@ -104,7 +104,6 @@ class Utilities(Configs):
|
|||
for line in lines:
|
||||
if line.startswith('BUILD=$'):
|
||||
build = ''.join(re.findall(r'\d+', line))
|
||||
|
||||
return build
|
||||
|
||||
@staticmethod
|
||||
|
@ -117,7 +116,6 @@ class Utilities(Configs):
|
|||
def read_packages_from_file(self, file: Path) -> Generator:
|
||||
""" Reads packages from file and split these to list. """
|
||||
try:
|
||||
|
||||
with open(file, 'r', encoding='utf-8') as pkgs:
|
||||
packages: list = pkgs.read().splitlines()
|
||||
|
||||
|
@ -125,9 +123,7 @@ class Utilities(Configs):
|
|||
if package and not package.startswith('#'):
|
||||
if '#' in package:
|
||||
package = package.split('#')[0].strip()
|
||||
|
||||
yield package
|
||||
|
||||
except FileNotFoundError:
|
||||
logger = logging.getLogger(LoggingConfig.date)
|
||||
logger.exception(f'{self.__class__.__name__}: '
|
||||
|
@ -166,7 +162,6 @@ class Utilities(Configs):
|
|||
def convert_file_sizes(size: int) -> str:
|
||||
""" Convert file sizes. """
|
||||
units: tuple = ('KB', 'MB', 'GB')
|
||||
|
||||
for unit in units:
|
||||
if size < 1000:
|
||||
return f'{size:.0f} {unit}'
|
||||
|
@ -176,11 +171,9 @@ class Utilities(Configs):
|
|||
def apply_package_pattern(data: dict, packages: list) -> list:
|
||||
""" If the '*' applied returns all the package names. """
|
||||
for pkg in packages:
|
||||
|
||||
if pkg == '*':
|
||||
packages.remove(pkg)
|
||||
packages.extend(list(data.keys()))
|
||||
|
||||
return packages
|
||||
|
||||
def blacklist_pattern(self, name: str) -> bool:
|
||||
|
|
Loading…
Reference in a new issue