Fixed for typing

This commit is contained in:
Dimitris Zlatanidis 2023-03-20 20:25:25 +02:00
parent 72015a1ecb
commit 89d93977ae
7 changed files with 23 additions and 20 deletions

View file

@ -17,7 +17,7 @@ class Load:
self.endc: str = '\x1b[0m'
self.bred: str = f'{bold}{red}'
def config_file(self, path: str, file: str) -> dict: # type: ignore
def config_file(self, path: Path, file: str) -> dict: # type: ignore
try:
""" Load the configs from the file. """
config_path_file = Path(path, f'{file}.toml')
@ -48,13 +48,13 @@ class Configs:
prog_name: str = 'slpkg'
os_arch: str = platform.machine()
tmp_path: str = '/tmp/'
tmp_slpkg: str = Path(tmp_path, prog_name)
build_path: str = Path(tmp_path, prog_name, 'build')
download_only_path: str = Path(tmp_slpkg, '')
lib_path: str = Path('/var/lib', prog_name)
etc_path: str = Path('/etc', prog_name)
db_path: str = Path(lib_path, 'database')
log_packages: str = Path('/var', 'log', 'packages')
tmp_slpkg: Path = Path(tmp_path, prog_name)
build_path: Path = Path(tmp_path, prog_name, 'build')
download_only_path: Path = Path(tmp_slpkg, '')
lib_path: Path = Path('/var/lib', prog_name)
etc_path: Path = Path('/etc', prog_name)
db_path: Path = Path(lib_path, 'database')
log_packages: Path = Path('/var', 'log', 'packages')
database_name: str = f'database.{prog_name}'
file_list_suffix: str = '.pkgs'

View file

@ -17,11 +17,11 @@ from slpkg.models.models import session as Session
class Download(Configs, Utilities):
""" Download the slackbuilds with the sources only. """
def __init__(self, directory: str, flags: list):
def __init__(self, directory: Path, flags: list):
super(Configs, self).__init__()
super(Utilities, self).__init__()
self.flags: list = flags
self.directory: str = directory
self.directory: Path = directory
self.repos = Repositories()
self.session = Session

View file

@ -514,7 +514,7 @@ class Argparse(Configs):
views = ViewMessage(self.flags)
views.question()
self.utils.remove_folder_if_exists(f'{self.tmp_path}{self.prog_name}')
self.utils.remove_folder_if_exists(Path(self.tmp_path, self.prog_name))
self.utils.create_folder(path=self.tmp_slpkg, folder='build')
print(f"The folder '{self.tmp_path}{self.prog_name}' was cleaned!")

View file

@ -48,7 +48,7 @@ class Repositories(Configs):
self.repo_tag: str = self.sbo_repo_tag
def configs(self) -> None:
""" Reads the repositories file. """
""" The repositories.toml configurations file. """
if self.repositories_file_toml.is_file():
try:

View file

@ -150,17 +150,19 @@ class Slackbuilds(Configs):
if self.is_not_for_skipped(sbo):
self.utils.remove_folder_if_exists(f'{self.build_path}{sbo}')
build_path: Path = Path(self.build_path, sbo)
self.utils.remove_folder_if_exists(build_path)
location: str = SBoQueries(sbo).location()
slackbuild = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
# Copy slackbuilds to the build folder.
if self.repos.ponce_repo:
path_ponce_repo_package = Path(self.repos.ponce_repo_path, location, sbo)
shutil.copytree(path_ponce_repo_package, f'{self.build_path}{sbo}')
shutil.copytree(path_ponce_repo_package, build_path)
else:
path_sbo_repo_package = Path(self.repos.sbo_repo_path, location, sbo)
shutil.copytree(path_sbo_repo_package, f'{self.build_path}{sbo}')
shutil.copytree(path_sbo_repo_package, build_path)
os.chmod(slackbuild, 0o775)
sources[sbo] = SBoQueries(sbo).sources()
@ -278,7 +280,7 @@ class Slackbuilds(Configs):
return max(packages)
def build_the_script(self, path: str, name: str) -> None:
def build_the_script(self, path: Path, name: str) -> None:
""" Run the .SlackBuild script. """
folder: str = f'{Path(path, name)}/'
execute: str = f'{folder}./{name}.SlackBuild'

View file

@ -78,14 +78,14 @@ class Utilities:
archive.unlink()
@staticmethod
def remove_folder_if_exists(folder: str) -> None:
def remove_folder_if_exists(folder: Path) -> None:
""" Clean the old folders. """
directory = Path(folder)
if directory.exists():
shutil.rmtree(directory)
@staticmethod
def create_folder(path: str, folder: str) -> None:
def create_folder(path: Path, folder: str) -> None:
""" Creates folder. """
directory = Path(path, folder)
if not directory.exists():

View file

@ -3,6 +3,7 @@
import os
from typing import Any
from pathlib import Path
from slpkg.configs import Configs
from slpkg.views.ascii import Ascii
@ -106,12 +107,12 @@ class ViewMessage(Configs):
self.summary(slackbuilds, dependencies, option=mode)
def download_packages(self, slackbuilds: list, directory: str) -> None:
def download_packages(self, slackbuilds: list, directory: Path) -> None:
""" View downloaded packages. """
self.ascii.draw_package_title_box('The following packages will be downloaded:', 'Download Packages')
if directory:
self.download_only: str = directory
self.download_only: Path = directory
for sbo in slackbuilds:
version: str = SBoQueries(sbo).version()