mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Refactor method & docstrings
This commit is contained in:
parent
6e47343f1c
commit
0507c3a8ae
1 changed files with 16 additions and 30 deletions
|
@ -24,10 +24,7 @@ from slpkg.views.view_process import ViewProcess
|
|||
|
||||
|
||||
class Packages(Configs): # pylint: disable=[R0902]
|
||||
|
||||
"""
|
||||
Download and install packages with dependencies.
|
||||
"""
|
||||
"""Download and install packages with dependencies."""
|
||||
|
||||
def __init__(self, repository: str, data: dict, packages: list, flags: list, mode: str): # pylint: disable=[R0913]
|
||||
super(Configs, self).__init__()
|
||||
|
@ -65,8 +62,7 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.packages: list = self.utils.apply_package_pattern(data, packages)
|
||||
|
||||
def execute(self) -> None:
|
||||
""" Calls methods in order.
|
||||
"""
|
||||
"""Calls methods in order."""
|
||||
self.view_process.message('Resolving dependencies')
|
||||
self.creating_dependencies_list()
|
||||
self.choose_package_dependencies()
|
||||
|
@ -81,7 +77,7 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
|
||||
start: float = time.time()
|
||||
self.view.skipping_packages(self.skipped_packages)
|
||||
self.crating_the_package_urls_list()
|
||||
self.creating_the_package_urls_list()
|
||||
self.checksum_binary_packages()
|
||||
self.set_progress_message()
|
||||
self.install_packages()
|
||||
|
@ -90,8 +86,7 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def creating_dependencies_list(self) -> None:
|
||||
""" Creating the full list o f dependencies.
|
||||
"""
|
||||
"""Creating the full list of dependencies."""
|
||||
for package in self.packages:
|
||||
dependencies: tuple = Required(self.data, package, self.flags).resolve()
|
||||
|
||||
|
@ -101,25 +96,21 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.dependencies: list = list(OrderedDict.fromkeys(self.dependencies))
|
||||
|
||||
def add_dependencies_to_install_order(self) -> None:
|
||||
""" Adds dependencies in order to install.
|
||||
"""
|
||||
"""Adds dependencies in order to install. """
|
||||
self.install_order.extend(self.dependencies)
|
||||
|
||||
def clean_the_main_slackbuilds(self) -> None:
|
||||
""" Removes packages that already listed in dependencies.
|
||||
"""
|
||||
"""Removes packages that already listed in dependencies."""
|
||||
for dependency in self.dependencies:
|
||||
if dependency in self.packages:
|
||||
self.packages.remove(dependency)
|
||||
|
||||
def add_main_packages_to_install_order(self) -> None:
|
||||
""" Adds main packages in order to install.
|
||||
"""
|
||||
"""Adds main packages in order to install."""
|
||||
self.install_order.extend(self.packages)
|
||||
|
||||
def check_for_skipped(self) -> None:
|
||||
""" Skip packages by user.
|
||||
"""
|
||||
"""Skip packages by user."""
|
||||
if self.option_for_skip_installed:
|
||||
for name in self.install_order:
|
||||
installed: str = self.utils.is_package_installed(name)
|
||||
|
@ -129,9 +120,8 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
# Remove packages from skipped packages.
|
||||
self.install_order: list = [pkg for pkg in self.install_order if pkg not in self.skipped_packages]
|
||||
|
||||
def crating_the_package_urls_list(self) -> None:
|
||||
""" Prepare package urls for downloading.
|
||||
"""
|
||||
def creating_the_package_urls_list(self) -> None:
|
||||
"""Prepare package urls for downloading."""
|
||||
packages: dict = {}
|
||||
asc_files: list = []
|
||||
if self.install_order:
|
||||
|
@ -158,7 +148,7 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.gpg.verify(asc_files)
|
||||
|
||||
def download_the_binary_packages(self, packages: dict) -> None:
|
||||
""" Download the packages.
|
||||
"""Download the packages.
|
||||
|
||||
Args:
|
||||
packages (dict): Packages for downloading.
|
||||
|
@ -169,16 +159,14 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
print()
|
||||
|
||||
def checksum_binary_packages(self) -> None:
|
||||
""" Checksum packages.
|
||||
"""
|
||||
"""Checksum packages."""
|
||||
for package in self.binary_packages:
|
||||
name: str = self.utils.split_package(Path(package).stem)['name']
|
||||
pkg_checksum: str = self.data[name]['checksum']
|
||||
self.check_md5.md5sum(self.tmp_slpkg, package, pkg_checksum)
|
||||
|
||||
def install_packages(self) -> None:
|
||||
""" Install the packages.
|
||||
"""
|
||||
"""Install the packages."""
|
||||
# Remove old slpkg.log file.
|
||||
if self.slpkg_log_file.is_file():
|
||||
self.slpkg_log_file.unlink()
|
||||
|
@ -196,7 +184,7 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.write_deps_log(name)
|
||||
|
||||
def write_deps_log(self, name: str) -> None:
|
||||
""" Create log file with installed packages with dependencies.
|
||||
"""Create log file with installed packages with dependencies.
|
||||
|
||||
Args:
|
||||
name (str): Package name.
|
||||
|
@ -217,14 +205,12 @@ class Packages(Configs): # pylint: disable=[R0902]
|
|||
self.deps_log_file.write_text(json.dumps(deps_logs, indent=4), encoding='utf-8')
|
||||
|
||||
def set_progress_message(self) -> None:
|
||||
""" Set message for upgrade method.
|
||||
"""
|
||||
"""Set message for upgrade method."""
|
||||
if self.mode == 'upgrade' or self.option_for_reinstall:
|
||||
self.progress_message: str = f'{self.violet}Upgrading{self.endc}'
|
||||
|
||||
def choose_package_dependencies(self) -> None:
|
||||
""" Choose dependencies for install with dialog tool.
|
||||
"""
|
||||
"""Choose dependencies for install with dialog tool."""
|
||||
if self.dependencies and self.dialog:
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
|
|
Loading…
Reference in a new issue