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