mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Refactor for view
This commit is contained in:
parent
9dc5bf3f7d
commit
9160531259
8 changed files with 39 additions and 39 deletions
|
@ -9,11 +9,11 @@ from collections import OrderedDict
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.checksum import Md5sum
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.views.views import View
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.logging_deps import LoggingDeps
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.multi_process import MultiProcess
|
||||
|
@ -35,7 +35,7 @@ class Packages(Configs):
|
|||
self.multi_proc = MultiProcess(flags)
|
||||
self.logs_deps = LoggingDeps(repository, data)
|
||||
self.upgrade = Upgrade(repository, data)
|
||||
self.view_message = ViewMessage(flags, repository, data)
|
||||
self.view = View(flags, repository, data)
|
||||
self.check_md5 = Md5sum(flags)
|
||||
self.download = Downloader(flags)
|
||||
self.ascii = AsciiBox()
|
||||
|
@ -66,8 +66,8 @@ class Packages(Configs):
|
|||
self.clean_the_main_slackbuilds()
|
||||
self.add_main_packages_to_install_order()
|
||||
|
||||
self.view_message.install_upgrade_packages(self.packages, self.dependencies, self.mode)
|
||||
self.view_message.question()
|
||||
self.view.install_upgrade_packages(self.packages, self.dependencies, self.mode)
|
||||
self.view.question()
|
||||
|
||||
start: float = time.time()
|
||||
self.crating_the_package_urls_list()
|
||||
|
@ -120,7 +120,7 @@ class Packages(Configs):
|
|||
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
|
||||
else:
|
||||
installed_package: str = self.utils.is_package_installed(pkg)
|
||||
self.view_message.view_skipping_packages(installed_package)
|
||||
self.view.skipping_packages(installed_package)
|
||||
|
||||
self.download_the_binary_packages(packages)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from urllib.parse import unquote
|
|||
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.error_messages import Errors
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.views.views import View
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Md5sum:
|
|||
self.ascii = AsciiBox()
|
||||
self.errors = Errors()
|
||||
self.utils = Utilities()
|
||||
self.view = ViewMessage(flags)
|
||||
self.view = View(flags)
|
||||
|
||||
logging.basicConfig(filename=LoggingConfig.log_file,
|
||||
filemode=LoggingConfig.filemode,
|
||||
|
|
|
@ -6,7 +6,7 @@ from pathlib import Path, PosixPath
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.views.views import View
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import (Base, engine, LogsDependencies,
|
||||
|
@ -21,7 +21,7 @@ class Cleanings(Configs):
|
|||
super(Configs, self).__init__()
|
||||
self.session = Session
|
||||
|
||||
self.view = ViewMessage()
|
||||
self.view = View()
|
||||
self.repos = Repositories()
|
||||
self.utils = Utilities()
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.views.views import View
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
@ -25,7 +25,7 @@ class DownloadOnly(Configs):
|
|||
self.data: dict = data
|
||||
self.repository: str = repository
|
||||
|
||||
self.view = ViewMessage(flags, repository, data)
|
||||
self.view = View(flags, repository, data)
|
||||
self.download = Downloader(flags)
|
||||
self.repos = Repositories()
|
||||
self.utils = Utilities()
|
||||
|
|
|
@ -7,7 +7,7 @@ import time
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.views.views import View
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.multi_process import MultiProcess
|
||||
from slpkg.models.models import LogsDependencies
|
||||
|
@ -28,7 +28,7 @@ class RemovePackages(Configs):
|
|||
self.utils = Utilities()
|
||||
self.ascii = AsciiBox()
|
||||
self.multi_proc = MultiProcess(flags)
|
||||
self.view = ViewMessage(flags)
|
||||
self.view = View(flags)
|
||||
|
||||
self.logs_dependencies: dict = {}
|
||||
self.packages_for_remove: list = []
|
||||
|
|
|
@ -13,12 +13,12 @@ from multiprocessing import cpu_count
|
|||
from slpkg.checksum import Md5sum
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.upgrade import Upgrade
|
||||
from slpkg.views.views import View
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.dialog_box import DialogBox
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.error_messages import Errors
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.logging_deps import LoggingDeps
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.multi_process import MultiProcess
|
||||
|
@ -44,7 +44,7 @@ class Slackbuilds(Configs):
|
|||
self.multi_proc = MultiProcess(flags)
|
||||
self.logs_deps = LoggingDeps(repository, data)
|
||||
self.upgrade = Upgrade(repository, data)
|
||||
self.view_message = ViewMessage(flags, repository, data)
|
||||
self.view = View(flags, repository, data)
|
||||
self.check_md5 = Md5sum(flags)
|
||||
self.download = Downloader(flags)
|
||||
self.ascii = AsciiBox()
|
||||
|
@ -125,11 +125,11 @@ class Slackbuilds(Configs):
|
|||
|
||||
def view_slackbuilds_before_build(self) -> None:
|
||||
if self.mode == 'build':
|
||||
self.view_message.build_packages(self.slackbuilds, self.dependencies)
|
||||
self.view.build_packages(self.slackbuilds, self.dependencies)
|
||||
else:
|
||||
self.view_message.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||
self.view.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||
|
||||
self.view_message.question()
|
||||
self.view.question()
|
||||
|
||||
def continue_build_or_install(self, name: str) -> bool:
|
||||
""" Skip installed package when the option --skip-installed is applied
|
||||
|
@ -206,7 +206,7 @@ class Slackbuilds(Configs):
|
|||
self.logs_deps.logging(sbo)
|
||||
else:
|
||||
installed_package: str = self.utils.is_package_installed(sbo)
|
||||
self.view_message.view_skipping_packages(installed_package)
|
||||
self.view.skipping_packages(installed_package)
|
||||
|
||||
def patch_slackbuild_tag(self, sbo: str) -> None:
|
||||
sbo_script: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||
|
|
|
@ -7,7 +7,7 @@ from multiprocessing import Process, Queue
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.views.views import View
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.install_data import InstallData
|
||||
from slpkg.repositories import Repositories
|
||||
|
@ -29,7 +29,7 @@ class UpdateRepository(Configs):
|
|||
self.repository: str = repository
|
||||
|
||||
self.session = Session
|
||||
self.view = ViewMessage(flags)
|
||||
self.view = View(flags)
|
||||
self.repos = Repositories()
|
||||
self.progress = ProgressBar()
|
||||
self.utils = Utilities()
|
||||
|
|
|
@ -12,7 +12,7 @@ from slpkg.dialog_box import DialogBox
|
|||
from slpkg.views.asciibox import AsciiBox
|
||||
|
||||
|
||||
class ViewMessage(Configs):
|
||||
class View(Configs):
|
||||
|
||||
def __init__(self, flags=None, repository=None, data=None):
|
||||
super(Configs, self).__init__()
|
||||
|
@ -46,16 +46,16 @@ class ViewMessage(Configs):
|
|||
'slpkg build packages')
|
||||
|
||||
for slackbuild in slackbuilds:
|
||||
self.view_build_package(slackbuild)
|
||||
self.build_package(slackbuild)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for dependency in dependencies:
|
||||
self.view_build_package(dependency)
|
||||
self.build_package(dependency)
|
||||
|
||||
self.view_summary(slackbuilds, dependencies, option=mode)
|
||||
self.summary(slackbuilds, dependencies, option=mode)
|
||||
|
||||
def install_upgrade_packages(self, packages: list, dependencies: list, mode: str) -> None:
|
||||
title: str = 'slpkg install packages'
|
||||
|
@ -64,16 +64,16 @@ class ViewMessage(Configs):
|
|||
self.ascii.draw_package_title('The following packages will be installed or upgraded:', title)
|
||||
|
||||
for package in packages:
|
||||
self.view_install_upgrade_package(package)
|
||||
self.install_upgrade_package(package)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for dependency in dependencies:
|
||||
self.view_install_upgrade_package(dependency)
|
||||
self.install_upgrade_package(dependency)
|
||||
|
||||
self.view_summary(packages, dependencies, option=mode)
|
||||
self.summary(packages, dependencies, option=mode)
|
||||
|
||||
def download_packages(self, packages: list, directory: Path) -> None:
|
||||
mode: str = 'download'
|
||||
|
@ -82,27 +82,27 @@ class ViewMessage(Configs):
|
|||
'slpkg download packages')
|
||||
|
||||
for package in packages:
|
||||
self.view_download_package(package)
|
||||
self.download_package(package)
|
||||
|
||||
self.view_summary(packages, dependencies=[], option=mode)
|
||||
self.summary(packages, dependencies=[], option=mode)
|
||||
|
||||
def remove_packages(self, packages: list, dependencies: list) -> Any:
|
||||
mode: str = 'remove'
|
||||
self.ascii.draw_package_title('The following packages will be removed:',
|
||||
'slpkg remove packages')
|
||||
for package in packages:
|
||||
self.view_remove_package(package)
|
||||
self.remove_package(package)
|
||||
|
||||
if dependencies:
|
||||
self.ascii.draw_middle_line()
|
||||
self.ascii.draw_dependency_line()
|
||||
|
||||
for dependency in dependencies:
|
||||
self.view_remove_package(dependency)
|
||||
self.remove_package(dependency)
|
||||
|
||||
self.view_summary(packages, dependencies, option=mode)
|
||||
self.summary(packages, dependencies, option=mode)
|
||||
|
||||
def view_build_package(self, package: str) -> None:
|
||||
def build_package(self, package: str) -> None:
|
||||
size: str = ''
|
||||
color: str = self.yellow
|
||||
version: str = self.data[package]['version']
|
||||
|
@ -114,7 +114,7 @@ class ViewMessage(Configs):
|
|||
|
||||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def view_install_upgrade_package(self, package: str) -> None:
|
||||
def install_upgrade_package(self, package: str) -> None:
|
||||
size: str = ''
|
||||
color: str = self.cyan
|
||||
version: str = self.data[package]['version']
|
||||
|
@ -139,7 +139,7 @@ class ViewMessage(Configs):
|
|||
|
||||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def view_download_package(self, package: str) -> None:
|
||||
def download_package(self, package: str) -> None:
|
||||
size: str = ''
|
||||
color: str = self.cyan
|
||||
version: str = self.data[package]['version']
|
||||
|
@ -151,7 +151,7 @@ class ViewMessage(Configs):
|
|||
|
||||
self.ascii.draw_package_line(package, version, size, color, self.repository)
|
||||
|
||||
def view_remove_package(self, package: str) -> None:
|
||||
def remove_package(self, package: str) -> None:
|
||||
installed: str = self.utils.is_package_installed(package)
|
||||
version: str = self.utils.split_package(installed)['version']
|
||||
repo_tag: str = self.utils.split_package(installed)['tag']
|
||||
|
@ -168,7 +168,7 @@ class ViewMessage(Configs):
|
|||
|
||||
print('Note: After cleaning you should remove them one by one.')
|
||||
|
||||
def view_summary(self, packages: list, dependencies: list, option: str) -> None:
|
||||
def summary(self, packages: list, dependencies: list, option: str) -> None:
|
||||
packages.extend(dependencies)
|
||||
install = upgrade = remove = size_comp = size_uncomp = size_rmv = int()
|
||||
|
||||
|
@ -239,7 +239,7 @@ class ViewMessage(Configs):
|
|||
version: str = self.utils.split_package(installed_package)['version']
|
||||
return f'{package}-{version}'
|
||||
|
||||
def view_skipping_packages(self, filename: str) -> None:
|
||||
def skipping_packages(self, filename: str) -> None:
|
||||
failed: str = f'{self.red}{self.ascii.skipped}{self.endc}'
|
||||
print(f"\r{'':>2}{self.bred}{self.ascii.bullet}{self.endc} {filename} {failed}{' ' * 17}")
|
||||
|
||||
|
|
Loading…
Reference in a new issue