mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Improved code quality
This commit is contained in:
parent
d0c0b57712
commit
fe31ca058e
1 changed files with 23 additions and 4 deletions
|
@ -10,7 +10,10 @@ from slpkg.dialog_box import DialogBox
|
|||
|
||||
|
||||
class Choose(Configs):
|
||||
""" Choose packages with dialog utility and -S, --search flag. """
|
||||
|
||||
"""
|
||||
Choose packages with dialog utility and -S, --search flag.
|
||||
"""
|
||||
|
||||
def __init__(self, repository: str):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -25,6 +28,19 @@ class Choose(Configs):
|
|||
self.list_height: int = 0
|
||||
|
||||
def packages(self, data: dict, packages: list, method: str) -> list:
|
||||
""" Calls methods to choosing packages via dialog tool.
|
||||
|
||||
Args:
|
||||
data (dict): Repository data.
|
||||
packages (list): List of packages.
|
||||
method (str): Type of method.
|
||||
|
||||
Returns:
|
||||
list: Name of packages.
|
||||
|
||||
Raises:
|
||||
SystemExit: Exit code 0.
|
||||
"""
|
||||
if self.dialog:
|
||||
title: str = f' Choose packages you want to {method} '
|
||||
|
||||
|
@ -51,7 +67,8 @@ class Choose(Configs):
|
|||
return packages
|
||||
|
||||
def choose_from_installed(self, packages: list) -> None:
|
||||
""" Choose installed packages for remove or find. """
|
||||
""" Choose installed packages for remove or find.
|
||||
"""
|
||||
for name, package in self.utils.all_installed().items():
|
||||
version: str = self.utils.split_package(package)['version']
|
||||
|
||||
|
@ -60,7 +77,8 @@ class Choose(Configs):
|
|||
self.choices.extend([(name, version, False, f'Package: {package}')])
|
||||
|
||||
def choose_for_upgraded(self, data: dict, packages: list) -> None:
|
||||
""" Choose packages that they will going to upgrade. """
|
||||
""" Choose packages that they will going to upgrade.
|
||||
"""
|
||||
for package in sorted(packages):
|
||||
|
||||
inst_package: str = self.utils.is_package_installed(package)
|
||||
|
@ -81,7 +99,8 @@ class Choose(Configs):
|
|||
f'Available: {repo_ver} Build: {repo_build_tag}')])
|
||||
|
||||
def choose_for_others(self, data: dict, packages: list) -> None:
|
||||
""" Choose packages for others methods like install, tracking etc. """
|
||||
""" Choose packages for others methods like install, tracking etc.
|
||||
"""
|
||||
if self.repository == '*':
|
||||
for pkg in sorted(packages):
|
||||
for repo_name, repo_data in data.items():
|
||||
|
|
Loading…
Reference in a new issue