Updated docstrings

This commit is contained in:
Dimitris Zlatanidis 2024-05-20 22:13:52 +03:00
parent 6283c34ec4
commit 48cc76a8e4

View file

@ -16,11 +16,8 @@ from slpkg.multi_process import MultiProcess
class RemovePackages(Configs): # pylint: disable=[R0902] class RemovePackages(Configs): # pylint: disable=[R0902]
"""Removes installed packages with dependencies if they
""" installed with slpkg install command."""
Removes installed packages with dependencies if they installed with
slpkg install command.
"""
def __init__(self, packages: list, flags: list): def __init__(self, packages: list, flags: list):
super(Configs, self).__init__() super(Configs, self).__init__()
@ -43,7 +40,7 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
('-O', '--resolve-off'), flags) ('-O', '--resolve-off'), flags)
def remove(self, upgrade: bool = False) -> None: def remove(self, upgrade: bool = False) -> None:
""" Remove packages """Remove packages
Args: Args:
upgrade (bool, optional): Is packages comes from upgrade method. upgrade (bool, optional): Is packages comes from upgrade method.
@ -76,8 +73,7 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
self.utils.finished_time(elapsed_time) self.utils.finished_time(elapsed_time)
def add_packages_for_remove(self) -> None: def add_packages_for_remove(self) -> None:
""" Add packages for remove. """Add packages for remove."""
"""
for package in self.packages: for package in self.packages:
installed: str = self.utils.is_package_installed(package) installed: str = self.utils.is_package_installed(package)
if installed: if installed:
@ -90,8 +86,7 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
self.dependencies.append(dep) self.dependencies.append(dep)
def find_dependent(self) -> None: def find_dependent(self) -> None:
""" Find packages that depend on other packages. """Find packages that depend on other packages."""
"""
for package in self.packages_for_remove: for package in self.packages_for_remove:
name: str = self.utils.split_package(package)['name'] name: str = self.utils.split_package(package)['name']
for pkg, deps in self.deps_log.items(): for pkg, deps in self.deps_log.items():
@ -109,21 +104,19 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
print(f"{'':>2}{pkg} {self.grey}{ver}{self.endc}") print(f"{'':>2}{pkg} {self.grey}{ver}{self.endc}")
def remove_doubles_dependencies(self) -> None: def remove_doubles_dependencies(self) -> None:
""" Removes doubles packages. """Removes doubles packages."""
"""
self.dependencies: list = list(set(self.dependencies)) self.dependencies: list = list(set(self.dependencies))
def add_installed_dependencies_to_remove(self) -> None: def add_installed_dependencies_to_remove(self) -> None:
""" Adds dependencies for remove. """Adds dependencies for remove."""
"""
for dep in self.dependencies: for dep in self.dependencies:
installed: str = self.utils.is_package_installed(dep) installed: str = self.utils.is_package_installed(dep)
if installed: if installed:
self.packages_for_remove.append(installed) self.packages_for_remove.append(installed)
def remove_packages(self) -> None: def remove_packages(self) -> None:
""" Remove packages. """Remove packages."""
"""
# Remove old slpkg.log file. # Remove old slpkg.log file.
if self.slpkg_log_file.is_file(): if self.slpkg_log_file.is_file():
self.slpkg_log_file.unlink() self.slpkg_log_file.unlink()
@ -141,7 +134,7 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
self.deps_log_file.write_text(json.dumps(self.deps_log, indent=4), encoding='utf-8') self.deps_log_file.write_text(json.dumps(self.deps_log, indent=4), encoding='utf-8')
def choose_packages_for_remove(self, packages: list, upgrade: bool = False) -> list: def choose_packages_for_remove(self, packages: list, upgrade: bool = False) -> list:
""" Choose packages via dialog utility. """Choose packages via dialog utility.
Args: Args:
packages (list): Description packages (list): Description
@ -173,7 +166,7 @@ class RemovePackages(Configs): # pylint: disable=[R0902]
return packages return packages
def remove_question(self) -> str | None: def remove_question(self) -> str | None:
""" Question about remove packages. """Question about remove packages.
Returns: Returns:
str | None: Answer. str | None: Answer.