diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 0be3981d..437d54c3 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -6,6 +6,7 @@ from slpkg.configs import Configs from slpkg.views.ascii import Ascii from slpkg.queries import SBoQueries from slpkg.utilities import Utilities +from slpkg.repositories import Repositories from slpkg.models.models import session as Session from slpkg.models.models import SBoTable, PonceTable @@ -21,6 +22,7 @@ class Dependees(Configs, Utilities): self.session = Session self.ascii = Ascii() + self.repos = Repositories() self.color = self.colour() self.llc: str = self.ascii.lower_left_corner @@ -38,7 +40,7 @@ class Dependees(Configs, Utilities): # Switch between sbo and ponce repository. self.sbo_table = SBoTable - if self.ponce_repo: + if self.repos.ponce_repo: self.sbo_table = PonceTable def slackbuilds(self) -> None: diff --git a/slpkg/download_only.py b/slpkg/download_only.py index e78daef9..46a12647 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -10,6 +10,7 @@ from slpkg.queries import SBoQueries from slpkg.utilities import Utilities from slpkg.downloader import Downloader from slpkg.views.views import ViewMessage +from slpkg.repositories import Repositories from slpkg.models.models import session as Session @@ -21,6 +22,7 @@ class Download(Configs, Utilities): super(Utilities, self).__init__() self.flags: list = flags self.directory: str = directory + self.repos = Repositories() self.session = Session @@ -40,12 +42,12 @@ class Download(Configs, Utilities): for sbo in slackbuilds: location: str = SBoQueries(sbo).location() - if self.ponce_repo: - ponce_repo_path_package = Path(self.ponce_repo_path, location, sbo) + if self.repos.ponce_repo: + ponce_repo_path_package = Path(self.repos.ponce_repo_path, location, sbo) shutil.copytree(ponce_repo_path_package, f'{download_path}{sbo}') else: - file: str = f'{sbo}{self.sbo_tar_suffix}' - url: list = [f'{self.sbo_repo_url}{location}/{file}'] + file: str = f'{sbo}{self.repos.sbo_repo_tar_suffix}' + url: list = [f'{self.repos.sbo_repo_url}{location}/{file}'] down_sbo = Downloader(download_path, url, self.flags) down_sbo.download() diff --git a/slpkg/form_configs.py b/slpkg/form_configs.py index 3b66eb0b..8459c6a1 100644 --- a/slpkg/form_configs.py +++ b/slpkg/form_configs.py @@ -31,7 +31,7 @@ class FormConfigs(Configs): """ Read and write the configuration file. """ self.is_dialog_enabled() elements: list = [] - height: int = 35 + height: int = 30 width: int = 74 text: str = f'Edit the configuration file: {self.config_file}' title: str = ' Configuration File ' @@ -69,8 +69,14 @@ class FormConfigs(Configs): def check_configs(self, tags: list) -> bool: """ Check for true of false values. """ - keys: list = ['COLORS', 'DIALOG', 'SILENT_MODE', 'ASCII_CHARACTERS', - 'PONCE_REPO', 'ASK_QUESTION', 'PARALLEL_DOWNLOADS'] + keys: list = [ + 'COLORS', + 'DIALOG', + 'SILENT_MODE', + 'ASCII_CHARACTERS', + 'ASK_QUESTION', + 'PARALLEL_DOWNLOADS' + ] values: list = ['true', 'false'] for key, value in zip(self.configs['CONFIGS'].keys(), tags): @@ -102,9 +108,14 @@ class FormConfigs(Configs): if line.lstrip().startswith(f'{key} ='): line = f' {key} = "{value}"\n' - if line.lstrip().startswith(('COLORS =', 'DIALOG =', 'SILENT_MODE =', - 'ASCII_CHARACTERS =', 'PONCE_REPO =', - 'ASK_QUESTION =', 'PARALLEL_DOWNLOADS =')): + if line.lstrip().startswith( + + ('COLORS =', 'DIALOG =', + 'SILENT_MODE =', + 'ASCII_CHARACTERS =', + 'ASK_QUESTION =', + 'PARALLEL_DOWNLOADS =') + ): line = line.replace('"', '') patch_toml.write(line) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 3c3b790c..374f7df9 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -20,8 +20,7 @@ class CreateData(Configs): self.session = Session self.utils = Utilities() self.query = SBoQueries('') - self.repositories = Repositories() - self.repos: dict = self.repositories.configs() + self.repos = Repositories() def install_sbo_table(self) -> None: """ Install the data for SBo repository. """ @@ -38,11 +37,11 @@ class CreateData(Configs): 'SLACKBUILD SHORT DESCRIPTION:' ] sbo_table = SBoTable - path = Path(self.sbo_repo_path, self.repos['SBO_REPO_TXT']) + path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_txt) - if self.repos['PONCE_REPO']: + if self.repos.ponce_repo: sbo_table = PonceTable - path = Path(self.ponce_repo_path, self.repos['PONCE_REPO_TXT']) + path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_txt) sbo_file: list = self.utils.read_file(path) @@ -82,7 +81,7 @@ class CreateData(Configs): 'PACKAGE SIZE (uncompressed):', 'PACKAGE DESCRIPTION:', ] - path = Path(self.lib_path, 'repositories', repo, self.repos['GNOME_REPO_PKG_TXT']) + path = Path(self.lib_path, 'repositories', repo, self.repos.gnome_repo_pkg_txt) pkg_txt: list = self.utils.read_file(path) diff --git a/slpkg/models/models.py b/slpkg/models/models.py index bf3cae94..82b897dd 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -25,17 +25,17 @@ class SBoTable(Base): __tablename__ = 'sbotable' - id: int = Column(Integer, primary_key=True) # type: ignore - name: str = Column(Text) # type: ignore - location: str = Column(Text) # type: ignore - files: str = Column(Text) # type: ignore - version: str = Column(Text) # type: ignore - download: str = Column(Text) # type: ignore - download64: str = Column(Text) # type: ignore - md5sum: str = Column(Text) # type: ignore - md5sum64: str = Column(Text) # type: ignore - requires: str = Column(Text) # type: ignore - short_description: str = Column(Text) # type: ignore + id: int = Column(Integer, primary_key=True) + name: str = Column(Text) + location: str = Column(Text) + files: str = Column(Text) + version: str = Column(Text) + download: str = Column(Text) + download64: str = Column(Text) + md5sum: str = Column(Text) + md5sum64: str = Column(Text) + requires: str = Column(Text) + short_description: str = Column(Text) @dataclass @@ -44,17 +44,17 @@ class PonceTable(Base): __tablename__ = 'poncetable' - id: int = Column(Integer, primary_key=True) # type: ignore - name: str = Column(Text) # type: ignore - location: str = Column(Text) # type: ignore - files: str = Column(Text) # type: ignore - version: str = Column(Text) # type: ignore - download: str = Column(Text) # type: ignore - download64: str = Column(Text) # type: ignore - md5sum: str = Column(Text) # type: ignore - md5sum64: str = Column(Text) # type: ignore - requires: str = Column(Text) # type: ignore - short_description: str = Column(Text) # type: ignore + id: int = Column(Integer, primary_key=True) + name: str = Column(Text) + location: str = Column(Text) + files: str = Column(Text) + version: str = Column(Text) + download: str = Column(Text) + download64: str = Column(Text) + md5sum: str = Column(Text) + md5sum64: str = Column(Text) + requires: str = Column(Text) + short_description: str = Column(Text) @dataclass @@ -63,19 +63,19 @@ class BinariesTable(Base): __tablename__ = 'binariestable' - id: int = Column(Integer, primary_key=True) # type: ignore - repo: str = Column(Text) # type: ignore - name: str = Column(Text) # type: ignore - version: str = Column(Text) # type: ignore - package: str = Column(Text) # type: ignore - mirror: str = Column(Text) # type: ignore - location: str = Column(Text) # type: ignore - size_comp: str = Column(Text) # type: ignore - size_uncomp: str = Column(Text) # type: ignore - requires: str = Column(Text) # type: ignore - conflicts: str = Column(Text) # type: ignore - suggests: str = Column(Text) # type: ignore - description: str = Column(Text) # type: ignore + id: int = Column(Integer, primary_key=True) + repo: str = Column(Text) + name: str = Column(Text) + version: str = Column(Text) + package: str = Column(Text) + mirror: str = Column(Text) + location: str = Column(Text) + size_comp: str = Column(Text) + size_uncomp: str = Column(Text) + requires: str = Column(Text) + conflicts: str = Column(Text) + suggests: str = Column(Text) + description: str = Column(Text) @dataclass @@ -84,9 +84,9 @@ class LogsDependencies(Base): __tablename__ = 'logsdependencies' - id: int = Column(Integer, primary_key=True) # type: ignore - name: str = Column(Text) # type: ignore - requires: str = Column(Text) # type: ignore + id: int = Column(Integer, primary_key=True) + name: str = Column(Text) + requires: str = Column(Text) Base.metadata.create_all(engine) diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index c3553e23..f4e83b85 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -20,6 +20,7 @@ from slpkg.dependencies import Requires from slpkg.downloader import Downloader from slpkg.views.views import ViewMessage from slpkg.progress_bar import ProgressBar +from slpkg.repositories import Repositories from slpkg.models.models import LogsDependencies from slpkg.models.models import session as Session @@ -35,6 +36,7 @@ class Slackbuilds(Configs): self.mode: str = mode self.session = Session + self.repos = Repositories() self.utils = Utilities() self.progress = ProgressBar() self.dialogbox = DialogBox() @@ -92,9 +94,9 @@ class Slackbuilds(Configs): # Checks if dependency exists in the ponce repository. # Sometimes the dependency reference is in the .info file, # but there is not exist in the repository as a folder. - if self.ponce_repo: + if self.repos.ponce_repo: location: str = SBoQueries(dep).location() - path_ponce_repo_package = Path(self.ponce_repo_path, location, dep) + path_ponce_repo_package = Path(self.repos.ponce_repo_path, location, dep) if not path_ponce_repo_package.is_dir(): continue @@ -153,11 +155,11 @@ class Slackbuilds(Configs): slackbuild = Path(self.build_path, sbo, f'{sbo}.SlackBuild') # Copy slackbuilds to the build folder. - if self.ponce_repo: - path_ponce_repo_package = Path(self.ponce_repo_path, location, sbo) + 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}') else: - path_sbo_repo_package = Path(self.sbo_repo_path, location, sbo) + path_sbo_repo_package = Path(self.repos.sbo_repo_path, location, sbo) shutil.copytree(path_sbo_repo_package, f'{self.build_path}{sbo}') os.chmod(slackbuild, 0o775) @@ -222,7 +224,7 @@ class Slackbuilds(Configs): with open(sbo_script, 'w') as script: for line in lines: if line.startswith('TAG=$'): - line: str = f'TAG=${{TAG:-{self.repo_tag}}}\n' + line: str = f'TAG=${{TAG:-{self.repos.repo_tag}}}\n' script.write(line) def logging_installed_dependencies(self, name: str) -> None: @@ -269,7 +271,7 @@ class Slackbuilds(Configs): installation. """ version: str = SBoQueries(name).version() - pattern: str = f'{name}-{version}*{self.repo_tag}*' + pattern: str = f'{name}-{version}*{self.repos.repo_tag}*' tmp = Path(self.tmp_path) packages: list = [file.name for file in tmp.glob(pattern)] diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 421c2f01..d43ae15b 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -133,7 +133,7 @@ class Utilities: def read_build_tag(self, sbo: str) -> str: """ Patching SBo TAG from the configuration file. """ location: str = SBoQueries(sbo).location() - sbo_script = Path(self.configs.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild') + sbo_script = Path(self.repos.sbo_repo_path, location, sbo, f'{sbo}.SlackBuild') if sbo_script.is_file(): with open(sbo_script, 'r', encoding='utf-8') as f: diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 558128e5..16bc0613 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -6,6 +6,7 @@ from pathlib import Path from slpkg.configs import Configs from slpkg.queries import SBoQueries from slpkg.utilities import Utilities +from slpkg.repositories import Repositories from slpkg.models.models import session as Session from slpkg.models.models import SBoTable, PonceTable @@ -18,18 +19,19 @@ class ViewPackage(Configs): self.flags: list = flags self.utils = Utilities() + self.repos = Repositories() self.session = Session self.flag_pkg_version: list = ['-p', '--pkg-version'] # Switch between sbo and ponce repository. self.sbo_table = SBoTable - self.repo_url: str = self.sbo_repo_url - self.repo_path: str = self.sbo_repo_path - self.repo_tar_suffix: str = self.sbo_tar_suffix - if self.ponce_repo: + self.repo_url: str = self.repos.sbo_repo_url + self.repo_path: Path = self.repos.sbo_repo_path + self.repo_tar_suffix: str = self.repos.sbo_repo_tar_suffix + if self.repos.ponce_repo: self.sbo_table = PonceTable - self.repo_url: str = self.ponce_repo_url - self.repo_path: str = self.ponce_repo_path + self.repo_url: str = self.repos.ponce_repo_url + self.repo_path: Path = self.repos.ponce_repo_path self.repo_tar_suffix: str = '' def package(self, packages: list) -> None: @@ -45,16 +47,16 @@ class ViewPackage(Configs): for package in packages: info: list = self.session.query( - self.sbo_table.name, # type: ignore - self.sbo_table.version, # type: ignore - self.sbo_table.requires, # type: ignore - self.sbo_table.download, # type: ignore - self.sbo_table.download64, # type: ignore - self.sbo_table.md5sum, # type: ignore - self.sbo_table.md5sum64, # type: ignore - self.sbo_table.files, # type: ignore - self.sbo_table.short_description, # type: ignore - self.sbo_table.location # type: ignore + self.sbo_table.name, + self.sbo_table.version, + self.sbo_table.requires, + self.sbo_table.download, + self.sbo_table.download64, + self.sbo_table.md5sum, + self.sbo_table.md5sum64, + self.sbo_table.files, + self.sbo_table.short_description, + self.sbo_table.location ).filter(self.sbo_table.name == package).first() path = Path(self.repo_path, info[9], info[0], 'README') @@ -66,7 +68,7 @@ class ViewPackage(Configs): repo_build_tag = self.utils.read_build_tag(info[0]) maintainer, email, homepage = '', '', '' - for line in info_file: # type: ignore + for line in info_file: if line.startswith('HOMEPAGE'): homepage: str = line[10:-2].strip() if line.startswith('MAINTAINER'):