Updated docstrings

This commit is contained in:
Dimitris Zlatanidis 2024-05-21 21:26:05 +03:00
parent d5218c6f52
commit 6e47343f1c
3 changed files with 27 additions and 47 deletions

View file

@ -6,8 +6,8 @@ from slpkg.utilities import Utilities
class Requires:
""" Creates a tuple of dependencies with
the right order to install. """
"""Creates a tuple of dependencies with
the right order to install."""
__slots__ = (
'data', 'name', 'flags', 'utils', 'option_for_resolve_off'
)
@ -21,7 +21,7 @@ class Requires:
('-O', '--resolve-off'), flags)
def resolve(self) -> tuple:
""" Resolve the dependencies. """
"""Resolve the dependencies."""
dependencies: tuple = ()
if not self.option_for_resolve_off:

View file

@ -8,17 +8,14 @@ from slpkg.views.asciibox import AsciiBox
class SBoGenerate(Configs):
"""
Generating the SLACKBUILDS.TXT file.
"""
"""Generating the SLACKBUILDS.TXT file."""
def __init__(self):
super(Configs, self).__init__()
self.ascii = AsciiBox()
def slackbuild_file(self, repo_path: Path, repo_slackbuild_txt: str) -> None: # pylint: disable=[R0914]
""" Creates a SLACKBUILDS.TXT file.
"""Creates a SLACKBUILDS.TXT file.
Args:
repo_path (Path): Path to file.
@ -90,14 +87,14 @@ class SBoGenerate(Configs):
@staticmethod
def read_short_description(path: Path, name: str) -> str:
""" Returns the short description.
"""Returns the short description from slack-desc file.
Args:
path (Path): Path to file.
name (str): Slackbuild name.
Returns:
str: Description
str: Short description
"""
slack_desc: Path = Path(path, 'slack-desc')
if slack_desc.is_file():

View file

@ -27,10 +27,7 @@ from slpkg.sbos.dependencies import Requires
class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
"""
Download build and install the SlackBuilds.
"""
"""Download, build and install the SlackBuilds."""
def __init__(self, repository: str, data: dict, slackbuilds: list, flags: list, mode: str): # pylint: disable=[R0913]
super(Configs, self).__init__()
@ -73,8 +70,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.tar_suffix: str = self.repos.repositories[repository]['tar_suffix']
def execute(self) -> None:
""" Calls the methods in order.
"""
"""Calls the methods in order."""
self.view_process.message('Resolving dependencies')
self.creating_dependencies_list()
self.choose_package_dependencies()
@ -98,8 +94,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.utils.finished_time(elapsed_time)
def creating_dependencies_list(self) -> None:
""" Creates the package dependencies list.
"""
"""Creates the package dependencies list."""
for slackbuild in self.slackbuilds:
dependencies: tuple = Requires(self.data, slackbuild, self.flags).resolve()
@ -109,25 +104,21 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.dependencies: list = list(OrderedDict.fromkeys(self.dependencies))
def add_dependencies_to_install_order(self) -> None:
""" Adds the dependency list in order for install.
"""
"""Adds the dependency list in order for install."""
self.install_order.extend(self.dependencies)
def clean_the_main_slackbuilds(self) -> None:
""" Removes main packages if they already added as dependency.
"""
"""Removes main packages if they already added as dependency."""
for dep in self.dependencies:
if dep in self.slackbuilds:
self.slackbuilds.remove(dep)
def add_main_packages_to_install_order(self) -> None:
""" Adds the main packages to order for install.
"""
"""Adds the main packages to order for install."""
self.install_order.extend(self.slackbuilds)
def check_for_skipped(self) -> None:
""" Checks packages for skipped.
"""
"""Checks packages for skipped."""
if self.option_for_skip_installed:
for name in self.install_order:
installed: str = self.utils.is_package_installed(name)
@ -138,16 +129,14 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.install_order: list = [pkg for pkg in self.install_order if pkg not in self.skipped_packages]
def view_slackbuilds_before_build(self) -> None:
""" View packages before build.
"""
"""View packages before build."""
if self.mode == 'build':
self.view.build_packages(self.slackbuilds, self.dependencies)
else:
self.view.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
def prepare_slackbuilds_for_build(self) -> None:
""" Prepare slackbuilds for build.
"""
"""Prepare slackbuilds for build."""
if self.install_order:
self.view_process.message('Prepare sources for downloading')
for sbo in self.install_order:
@ -178,8 +167,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.view_process.done()
def download_the_sources(self) -> None:
""" Download the sources.
"""
"""Download the sources."""
if self.sources:
print(f'Started to download total ({self.cyan}{len(self.sources)}{self.endc}) sources:\n')
self.download.download(self.sources)
@ -188,8 +176,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.checksum_downloaded_sources()
def checksum_downloaded_sources(self) -> None:
""" Checksum the sources.
"""
"""Checksum the sources."""
for sbo in self.install_order:
path: Path = Path(self.build_path, sbo)
@ -204,8 +191,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.check_md5.md5sum(path, source, checksum)
def build_and_install_the_slackbuilds(self) -> None:
""" Builds an install the slackbuilds.
"""
"""Builds an install the slackbuilds."""
# Remove old slpkg.log file.
if self.slpkg_log_file.is_file():
self.slpkg_log_file.unlink()
@ -224,7 +210,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.install_package(sbo)
def patch_slackbuild_tag(self, sbo: str) -> None:
""" Patch the slackbuild tag.
"""Patch the slackbuild tag.
Args:
sbo (str): Slackbuild name.
@ -240,7 +226,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
script.write(line)
def install_package(self, name: str) -> None:
""" Install the slackbuild.
"""Install the slackbuild.
Args:
name (str): Slackbuild name.
@ -255,7 +241,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.write_deps_log(name)
def write_deps_log(self, name: str) -> None:
""" Creates a log file with Slackbuild dependencies.
"""Creates a log file with Slackbuild dependencies.
Args:
name (str): Slackbuild name.
@ -276,7 +262,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.deps_log_file.write_text(json.dumps(deps_logs, indent=4), encoding='utf-8')
def find_package_for_install(self, name: str) -> str:
""" Find build slackbuilds for install.
"""Find build slackbuilds for install.
Args:
name (str): Package name.
@ -295,7 +281,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
return None
def build_the_script(self, path: Path, name: str) -> None:
""" Builds the slackbuild script.
"""Builds the slackbuild script.
Args:
path (Path): Path to build the script.
@ -310,19 +296,16 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.multi_proc.process_and_log(command, filename, progress_message)
def set_progress_message(self) -> None:
""" Set progress message for upgrade.
"""
"""Set progress message for upgrade."""
if self.mode == 'upgrade' or self.option_for_reinstall:
self.progress_message: str = f'{self.violet}Upgrading{self.endc}'
def set_makeflags(self) -> None:
""" Set makeflags.
"""
"""Set makeflags."""
os.environ['MAKEFLAGS'] = f'-j {self.makeflags}'
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