mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated docstrings
This commit is contained in:
parent
10bb95c941
commit
d5218c6f52
6 changed files with 42 additions and 69 deletions
|
@ -8,10 +8,7 @@ from slpkg.configs import Configs
|
|||
|
||||
|
||||
class AsciiBox(Configs): # pylint: disable=[R0902]
|
||||
|
||||
"""
|
||||
Managing the ASCII characters.
|
||||
"""
|
||||
"""Managing the ASCII characters."""
|
||||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -21,9 +18,6 @@ class AsciiBox(Configs): # pylint: disable=[R0902]
|
|||
self.size_alignment: int = 9
|
||||
self.repo_alignment: int = 14
|
||||
|
||||
# if self.package_alignment < 1:
|
||||
# self.package_alignment = 1
|
||||
|
||||
self.package_alignment = max(self.package_alignment, 1)
|
||||
|
||||
self.bd_color: str = self.endc
|
||||
|
@ -65,8 +59,7 @@ class AsciiBox(Configs): # pylint: disable=[R0902]
|
|||
self.vertical_and_left: str = '┤'
|
||||
|
||||
def assign_border_color(self) -> None:
|
||||
""" Assign the colors.
|
||||
"""
|
||||
"""Assign the colors."""
|
||||
self.border_colors: dict = {
|
||||
'red': self.red,
|
||||
'blue': self.blue,
|
||||
|
@ -86,7 +79,7 @@ class AsciiBox(Configs): # pylint: disable=[R0902]
|
|||
self.bd_color: str = self.endc
|
||||
|
||||
def draw_package_title(self, message: str, title: str) -> None:
|
||||
""" Draw the package title.
|
||||
"""Draw the package title.
|
||||
|
||||
Args:
|
||||
message (str): Message about the action.
|
||||
|
@ -105,7 +98,7 @@ class AsciiBox(Configs): # pylint: disable=[R0902]
|
|||
f"{self.bd_color}{self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_package_line(self, package: str, version: str, size: str, color: str, repo: str) -> None: # pylint: disable=[R0913]
|
||||
""" Draw the package line.
|
||||
"""Draw the package line.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -124,25 +117,22 @@ class AsciiBox(Configs): # pylint: disable=[R0902]
|
|||
f"{repo:>{self.repo_alignment}}{self.bd_color} {self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_middle_line(self) -> None:
|
||||
""" Draw the middle line
|
||||
"""
|
||||
"""Draw the middle line."""
|
||||
print(f"{self.bd_color}{self.vertical_and_right}{self.horizontal_line * (self.columns - 2)}"
|
||||
f"{self.vertical_and_left}")
|
||||
|
||||
def draw_dependency_line(self) -> None:
|
||||
""" Draw the dependency line.
|
||||
"""
|
||||
"""Draw the dependency line."""
|
||||
print(f"{self.bd_color}{self.vertical_line}{self.endc} Dependencies:{' ' * (self.columns - 16)}"
|
||||
f"{self.bd_color}{self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_bottom_line(self) -> None:
|
||||
""" Draw the bottom line.
|
||||
"""
|
||||
"""Draw the bottom line."""
|
||||
print(f"{self.bd_color}{self.lower_left_corner}{self.horizontal_line * (self.columns - 2)}"
|
||||
f"{self.lower_right_corner}{self.endc}")
|
||||
|
||||
def draw_checksum_error_box(self, name: str, checksum: str, file_check: str) -> None:
|
||||
""" Draw a checksum error box.
|
||||
"""Draw a checksum error box.
|
||||
|
||||
Args:
|
||||
name (str): Package name.
|
||||
|
|
|
@ -8,16 +8,13 @@ from slpkg.views.version import Version
|
|||
|
||||
|
||||
class Usage(Configs):
|
||||
|
||||
"""
|
||||
CLI Usage menu.
|
||||
"""
|
||||
"""CLI Usage menu."""
|
||||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
|
||||
def help_minimal(self, message: str) -> NoReturn:
|
||||
""" Prints the minimal help menu.
|
||||
"""Prints the minimal help menu.
|
||||
|
||||
Args:
|
||||
message (str): Message of error.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
class Version: # pylint: disable=[R0903]
|
||||
""" Print the version. """
|
||||
"""Print the version."""
|
||||
|
||||
def __init__(self):
|
||||
self.version: str = "5.0.9"
|
||||
|
@ -13,7 +13,7 @@ class Version: # pylint: disable=[R0903]
|
|||
self.email: str = 'dslackw@gmail.com'
|
||||
|
||||
def view(self) -> None:
|
||||
""" Prints the version. """
|
||||
"""Prints the version."""
|
||||
print(f'Version: {self.version}\n'
|
||||
f'Author: {self.author}\n'
|
||||
f'License: {self.license}\n'
|
||||
|
|
|
@ -10,10 +10,7 @@ from slpkg.repositories import Repositories
|
|||
|
||||
|
||||
class ViewPackage(Configs): # pylint: disable=[R0902]
|
||||
|
||||
"""
|
||||
View the packages information.
|
||||
"""
|
||||
"""View the packages information."""
|
||||
|
||||
def __init__(self, flags: list, repository: str):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -72,7 +69,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
self.view_slackbuild_package(name, item)
|
||||
|
||||
def read_the_readme_file(self, path_file: Path) -> None:
|
||||
""" Reads the README file.
|
||||
"""Reads the README file.
|
||||
|
||||
Args:
|
||||
path_file (Path): Path to the file.
|
||||
|
@ -80,7 +77,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
self.readme: list = self.utils.read_text_file(path_file)
|
||||
|
||||
def read_the_info_file(self, path_info: Path) -> None:
|
||||
""" reads the .info file.
|
||||
"""Reads the .info file.
|
||||
|
||||
Args:
|
||||
path_info (Path): Path to the file.
|
||||
|
@ -88,13 +85,11 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
self.info_file: list = self.utils.read_text_file(path_info)
|
||||
|
||||
def assign_the_sbo_mirror(self) -> None:
|
||||
""" Assign the url for the PACKAGES.TXT file.
|
||||
"""
|
||||
"""Assign the url for the PACKAGES.TXT file."""
|
||||
self.mirror: str = self.repos.repositories[self.repository]['mirror_packages']
|
||||
|
||||
def assign_the_info_file_variables(self) -> None:
|
||||
""" Assign data from the .info file.
|
||||
"""
|
||||
"""Assign data from the .info file."""
|
||||
for line in self.info_file:
|
||||
if line.startswith('HOMEPAGE'):
|
||||
self.homepage: str = line[10:-2].strip()
|
||||
|
@ -112,7 +107,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
self.dependencies: str = ', '.join([f'{self.cyan}{pkg}' for pkg in item['requires']])
|
||||
|
||||
def assign_dependencies_with_version(self, item: dict, data: dict) -> None:
|
||||
""" Assign dependencies with version.
|
||||
"""Assign dependencies with version.
|
||||
|
||||
Args:
|
||||
item (dict): Data value.
|
||||
|
@ -125,7 +120,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
if pkg in self.repository_packages]))
|
||||
|
||||
def view_slackbuild_package(self, name: str, item: dict) -> None:
|
||||
""" Prints slackbuild information.
|
||||
"""Prints slackbuild information.
|
||||
|
||||
Args:
|
||||
name (str): Slackbuild name.
|
||||
|
@ -153,7 +148,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
f"{'README':<15}: {self.cyan}{f'{space_align:>17}'.join(self.readme)}{self.endc}")
|
||||
|
||||
def package(self, data: dict, packages: list) -> None:
|
||||
""" View binary packages information.
|
||||
"""View binary packages information.
|
||||
|
||||
Args:
|
||||
data (dict): Repository data.
|
||||
|
@ -170,7 +165,7 @@ class ViewPackage(Configs): # pylint: disable=[R0902]
|
|||
self.view_binary_package(name, item)
|
||||
|
||||
def view_binary_package(self, name: str, item: dict) -> None:
|
||||
""" Print binary packages information.
|
||||
"""Print binary packages information.
|
||||
|
||||
Args:
|
||||
name (str): Package name.
|
||||
|
|
|
@ -12,10 +12,7 @@ from slpkg.views.asciibox import AsciiBox
|
|||
|
||||
|
||||
class ViewProcess(Configs):
|
||||
|
||||
"""
|
||||
View the process messages.
|
||||
"""
|
||||
"""View the process messages."""
|
||||
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -30,8 +27,7 @@ class ViewProcess(Configs):
|
|||
('-B', '--progress-bar'), flags)
|
||||
|
||||
def message(self, message: str) -> None:
|
||||
""" Show spinner with message or message.
|
||||
"""
|
||||
"""Show spinner with message or message."""
|
||||
if self.progress_bar_conf or self.option_for_progress_bar:
|
||||
self.bar_process = Process(target=self.progress.progress_bar, args=(message,))
|
||||
self.bar_process.start()
|
||||
|
@ -39,8 +35,7 @@ class ViewProcess(Configs):
|
|||
print(f'\r{message}... ', end='')
|
||||
|
||||
def done(self) -> None:
|
||||
""" Show done message.
|
||||
"""
|
||||
"""Show done message."""
|
||||
if self.progress_bar_conf or self.option_for_progress_bar:
|
||||
time.sleep(0.1)
|
||||
self.bar_process.terminate()
|
||||
|
@ -51,8 +46,7 @@ class ViewProcess(Configs):
|
|||
print(f'{self.bgreen}{self.ascii.done}{self.endc}')
|
||||
|
||||
def failed(self) -> None:
|
||||
""" Show for failed message.
|
||||
"""
|
||||
"""Show for failed message."""
|
||||
if self.progress_bar_conf or self.option_for_progress_bar:
|
||||
time.sleep(0.1)
|
||||
self.bar_process.terminate()
|
||||
|
|
|
@ -13,9 +13,7 @@ from slpkg.repositories import Repositories
|
|||
|
||||
|
||||
class View(Configs): # pylint: disable=[R0902]
|
||||
|
||||
""" Views packages for build, install, remove or download.
|
||||
"""
|
||||
"""Views packages for build, install, remove or download."""
|
||||
|
||||
def __init__(self, flags: list = None, repository: str = None, data: dict = None):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -51,7 +49,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
('-y', '--yes'), flags)
|
||||
|
||||
def build_packages(self, slackbuilds: list, dependencies: list) -> None:
|
||||
""" View packages for build method.
|
||||
"""View packages for build method.
|
||||
|
||||
Args:
|
||||
slackbuilds (list): Slackbuilds for build.
|
||||
|
@ -78,7 +76,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
print(self.summary_message)
|
||||
|
||||
def install_upgrade_packages(self, packages: list, dependencies: list, mode: str) -> None:
|
||||
""" View packages for install or upgrade.
|
||||
"""View packages for install or upgrade.
|
||||
|
||||
Args:
|
||||
packages (list): Packages for install.
|
||||
|
@ -109,7 +107,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
print(self.summary_message)
|
||||
|
||||
def download_packages(self, packages: list, directory: Path) -> None:
|
||||
""" View packages for download method.
|
||||
"""View packages for download method.
|
||||
|
||||
Args:
|
||||
packages (list): Packages name for download.
|
||||
|
@ -129,7 +127,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
print(self.summary_message)
|
||||
|
||||
def remove_packages(self, packages: list, dependencies: list) -> None:
|
||||
""" View packages for remove.
|
||||
"""View packages for remove.
|
||||
|
||||
Args:
|
||||
packages (list): List of packages.
|
||||
|
@ -155,7 +153,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
print(self.summary_message)
|
||||
|
||||
def draw_build_package(self, package: str) -> None:
|
||||
""" Draw line for build package method.
|
||||
"""Draw line for build package method.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -167,7 +165,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def draw_install_upgrade_package(self, package: str) -> None:
|
||||
""" Draw line for install or upgrade package method.
|
||||
"""Draw line for install or upgrade package method.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -196,7 +194,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def draw_download_package(self, package: str) -> None:
|
||||
""" Draw package for download method.
|
||||
"""Draw package for download method.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -212,7 +210,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def draw_remove_package(self, package: str) -> None:
|
||||
""" Draw package for remove method.
|
||||
"""Draw package for remove method.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -227,7 +225,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.ascii.draw_package_line(package, version, size, self.red, repository)
|
||||
|
||||
def summary(self, package: str) -> None:
|
||||
""" Counts packages per method.
|
||||
"""Counts packages per method.
|
||||
|
||||
Args:
|
||||
package (str): Package name.
|
||||
|
@ -256,7 +254,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.sum_remove += 1
|
||||
|
||||
def set_summary_for_build(self, packages: list) -> None:
|
||||
""" Sets summary message for build.
|
||||
"""Sets summary message for build.
|
||||
|
||||
Args:
|
||||
packages (list): List of packages.
|
||||
|
@ -266,7 +264,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
f'will be build in {self.tmp_path} folder.{self.endc}')
|
||||
|
||||
def set_summary_for_install_and_upgrade(self, install: int, upgrade: int, size_comp: int, size_uncomp: int) -> None:
|
||||
""" Sets summary for install or upgrade.
|
||||
"""Sets summary for install or upgrade.
|
||||
|
||||
Args:
|
||||
install (int): Counts for installs.
|
||||
|
@ -292,7 +290,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
self.summary_message: str = f'{total_packages}{split_message}{total_sizes}{custom_message}{upgrade_message}'
|
||||
|
||||
def set_summary_for_remove(self, remove: int, size_rmv: int) -> None:
|
||||
""" Sets summary for removes.
|
||||
"""Sets summary for removes.
|
||||
|
||||
Args:
|
||||
remove (int): Counts of removes.
|
||||
|
@ -304,7 +302,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
f'of space will be freed up.{self.endc}')
|
||||
|
||||
def set_summary_for_download(self, packages: list, size_comp: int) -> None:
|
||||
""" Sets summary for downloads.
|
||||
"""Sets summary for downloads.
|
||||
|
||||
Args:
|
||||
packages (list): List of packages.
|
||||
|
@ -328,7 +326,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
return f'{package}-{version}'
|
||||
|
||||
def skipping_packages(self, packages: list) -> None:
|
||||
""" View skipped packages.
|
||||
"""View skipped packages.
|
||||
|
||||
Args:
|
||||
packages (list): List of packages.
|
||||
|
@ -342,8 +340,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
print()
|
||||
|
||||
def missing_dependencies(self, packages: list) -> None:
|
||||
""" View for missing dependencies.
|
||||
"""
|
||||
"""View for missing dependencies."""
|
||||
if self.view_missing_deps:
|
||||
missing_deps: dict = {}
|
||||
for package in packages:
|
||||
|
@ -359,7 +356,7 @@ class View(Configs): # pylint: disable=[R0902]
|
|||
f"({len(deps)}) -> {self.red}{', '.join(deps)}{self.endc}")
|
||||
|
||||
def question(self, message: str = 'Do you want to continue?') -> None:
|
||||
""" View a question.
|
||||
"""View a question.
|
||||
|
||||
Args:
|
||||
message (str, optional): Message of question.
|
||||
|
|
Loading…
Reference in a new issue