mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Updated for type hinting
This commit is contained in:
parent
61bf3a970d
commit
448617db31
3 changed files with 48 additions and 48 deletions
|
@ -23,7 +23,7 @@ class Blacklist(Configs):
|
|||
|
||||
if self.ponce_repo:
|
||||
sbos = self.session.query(PonceTable.name).all()
|
||||
ponce_blacks = [sbo[0] for sbo in sbos]
|
||||
ponce_blacks: list = [sbo[0] for sbo in sbos]
|
||||
|
||||
if file_toml.is_file():
|
||||
try:
|
||||
|
|
|
@ -127,7 +127,7 @@ class Configs:
|
|||
removepkg: str = config['REMOVEPKG']
|
||||
|
||||
# Cli menu colors configs.
|
||||
colors: str = config['COLORS']
|
||||
colors: bool = config['COLORS']
|
||||
|
||||
# Dialog utility.
|
||||
dialog: str = config['DIALOG']
|
||||
|
|
|
@ -27,14 +27,14 @@ class Slackbuilds(Configs):
|
|||
|
||||
def __init__(self, slackbuilds: list, flags: list, file_pattern, mode: str):
|
||||
super(Configs, self).__init__()
|
||||
self.slackbuilds = slackbuilds
|
||||
self.flags = flags
|
||||
self.file_pattern = file_pattern
|
||||
self.mode = mode
|
||||
self.install_order = []
|
||||
self.dependencies = []
|
||||
self.sbos = {}
|
||||
self.output = 0
|
||||
self.slackbuilds: list = slackbuilds
|
||||
self.flags: list = flags
|
||||
self.file_pattern: str = file_pattern
|
||||
self.mode: str = mode
|
||||
self.install_order: list = []
|
||||
self.dependencies: list = []
|
||||
self.sbos: dict = {}
|
||||
self.output: int = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
self.process_message = None
|
||||
|
@ -44,18 +44,18 @@ class Slackbuilds(Configs):
|
|||
self.dialogbox = DialogBox()
|
||||
self.view_message = ViewMessage(self.flags)
|
||||
self.color = self.colour()
|
||||
self.bold = self.color['bold']
|
||||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.flag_reinstall = ['-R', '--reinstall']
|
||||
self.flag_skip_installed = ['-k', '--skip-installed']
|
||||
self.flag_resolve_off = ['-o', '--resolve-off']
|
||||
self.flag_jobs = ['-j', '--jobs']
|
||||
self.flag_no_silent = ['-n', '--no-silent']
|
||||
self.bold: str = self.color['bold']
|
||||
self.cyan: str = self.color['cyan']
|
||||
self.red: str = self.color['red']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.endc: str = self.color['endc']
|
||||
self.byellow: str = f'{self.bold}{self.yellow}'
|
||||
self.bred: str = f'{self.bold}{self.red}'
|
||||
self.flag_reinstall: list = ['-R', '--reinstall']
|
||||
self.flag_skip_installed: list = ['-k', '--skip-installed']
|
||||
self.flag_resolve_off: list = ['-o', '--resolve-off']
|
||||
self.flag_jobs: list = ['-j', '--jobs']
|
||||
self.flag_no_silent: list = ['-n', '--no-silent']
|
||||
|
||||
def execute(self):
|
||||
""" Starting build or install the slackbuilds. """
|
||||
|
@ -132,14 +132,14 @@ class Slackbuilds(Configs):
|
|||
|
||||
if self.is_for_skipped(sbo):
|
||||
|
||||
file = f'{sbo}{self.sbo_tar_suffix}'
|
||||
file: str = f'{sbo}{self.sbo_tar_suffix}'
|
||||
|
||||
self.utils.remove_file_if_exists(self.tmp_slpkg, file)
|
||||
self.utils.remove_folder_if_exists(self.build_path, sbo)
|
||||
|
||||
location = SBoQueries(sbo).location()
|
||||
sbo_url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
ponce_url = f'{self.ponce_url}/{location}/{sbo}'
|
||||
sbo_url: str = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
ponce_url: str = f'{self.ponce_url}/{location}/{sbo}'
|
||||
|
||||
if self.ponce_repo and self.ponce_url:
|
||||
path = Path(self.build_path, sbo)
|
||||
|
@ -213,19 +213,19 @@ class Slackbuilds(Configs):
|
|||
""" Install the packages that before created in the tmp directory. """
|
||||
pkg = self.utils.split_installed_pkg(package)[0]
|
||||
|
||||
execute = self.installpkg
|
||||
execute: str = self.installpkg
|
||||
if (self.utils.is_option(self.flag_reinstall, self.flags) and
|
||||
self.utils.is_installed(pkg, self.file_pattern)):
|
||||
execute = self.reinstall
|
||||
execute: str = self.reinstall
|
||||
|
||||
message = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message = f"'{pkg}' to install"
|
||||
message: str = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message: str = f"'{pkg}' to install"
|
||||
|
||||
if self.mode == 'upgrade':
|
||||
self.process_message = f"package '{pkg}' to upgrade"
|
||||
self.process_message: str = f"package '{pkg}' to upgrade"
|
||||
message = f'{self.cyan}Upgrade{self.endc}'
|
||||
|
||||
command = f'{execute} {self.tmp_path}/{package}'
|
||||
command: str = f'{execute} {self.tmp_path}/{package}'
|
||||
|
||||
self.multi_process(command, package, message)
|
||||
|
||||
|
@ -234,7 +234,7 @@ class Slackbuilds(Configs):
|
|||
installation. """
|
||||
version = SBoQueries(name).version()
|
||||
|
||||
pattern = f'{name}-{version}*{self.sbo_repo_tag}*'
|
||||
pattern: str = f'{name}-{version}*{self.sbo_repo_tag}*'
|
||||
|
||||
tmp = Path(self.tmp_path)
|
||||
packages = [file.name for file in tmp.glob(pattern)]
|
||||
|
@ -243,8 +243,8 @@ class Slackbuilds(Configs):
|
|||
|
||||
def build_the_script(self, path: str, name: str):
|
||||
""" Run the .SlackBuild script. """
|
||||
folder = f'{Path(path, name)}/'
|
||||
execute = f'{folder}./{name}.SlackBuild'
|
||||
folder: str = f'{Path(path, name)}/'
|
||||
execute: str = f'{folder}./{name}.SlackBuild'
|
||||
|
||||
# Change to root privileges
|
||||
os.chown(folder, 0, 0)
|
||||
|
@ -254,8 +254,8 @@ class Slackbuilds(Configs):
|
|||
if self.utils.is_option(self.flag_jobs, self.flags):
|
||||
self.set_makeflags()
|
||||
|
||||
message = f'{self.red}Build{self.endc}'
|
||||
self.process_message = f"package '{name}' to build"
|
||||
message: str = f'{self.red}Build{self.endc}'
|
||||
self.process_message: str = f"package '{name}' to build"
|
||||
|
||||
self.multi_process(execute, name, message)
|
||||
|
||||
|
@ -280,7 +280,7 @@ class Slackbuilds(Configs):
|
|||
""" Starting multiprocessing install/upgrade process. """
|
||||
if self.silent_mode and not self.utils.is_option(self.flag_no_silent, self.flags):
|
||||
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
done: str = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
||||
|
@ -298,7 +298,7 @@ class Slackbuilds(Configs):
|
|||
if not p1.is_alive():
|
||||
|
||||
if p1.exitcode != 0:
|
||||
done = f' {self.bred} Failed{self.endc}'
|
||||
done: str = f' {self.bred} Failed{self.endc}'
|
||||
self.output = p1.exitcode
|
||||
|
||||
print(f'{self.endc}{done}', end='')
|
||||
|
@ -314,7 +314,7 @@ class Slackbuilds(Configs):
|
|||
|
||||
self.print_error()
|
||||
|
||||
def process(self, command):
|
||||
def process(self, command: str):
|
||||
""" Processes execution. """
|
||||
self.output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
|
@ -328,25 +328,25 @@ class Slackbuilds(Configs):
|
|||
|
||||
def choose_dependencies(self, dependencies: list):
|
||||
""" Choose packages for install. """
|
||||
height = 10
|
||||
width = 70
|
||||
list_height = 0
|
||||
choices = []
|
||||
title = ' Choose dependencies you want to install '
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
list_height: int = 0
|
||||
choices: list = []
|
||||
title: str = ' Choose dependencies you want to install '
|
||||
|
||||
for package in dependencies:
|
||||
status = False
|
||||
status: bool = False
|
||||
repo_ver = SBoQueries(package).version()
|
||||
self.utils.is_package_upgradeable(package, self.file_pattern)
|
||||
|
||||
if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package, self.file_pattern):
|
||||
status = True
|
||||
status: bool = True
|
||||
|
||||
if self.mode == 'install' and not self.utils.is_installed(package, self.file_pattern):
|
||||
status = True
|
||||
status: bool = True
|
||||
|
||||
if self.mode == 'install' and self.utils.is_package_upgradeable(package, self.file_pattern):
|
||||
status = True
|
||||
status: bool = True
|
||||
|
||||
choices += [(package, repo_ver, status)]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue