From 33f18767296ab26b3c101ed3668ce7960e977369 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 14 Mar 2024 19:08:47 +0200 Subject: [PATCH] Remove models --- slpkg/binaries/queries.py | 41 --------------- slpkg/checks.py | 2 - slpkg/cleanings.py | 4 -- slpkg/download_only.py | 2 - slpkg/logging_deps.py | 3 -- slpkg/models/__init__.py | 0 slpkg/models/models.py | 102 -------------------------------------- slpkg/remove_packages.py | 3 -- slpkg/repo_info.py | 4 -- slpkg/sbos/queries.py | 48 ------------------ slpkg/search.py | 2 - 11 files changed, 211 deletions(-) delete mode 100644 slpkg/binaries/queries.py delete mode 100644 slpkg/models/__init__.py delete mode 100644 slpkg/models/models.py delete mode 100644 slpkg/sbos/queries.py diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py deleted file mode 100644 index 01d36bfd..00000000 --- a/slpkg/binaries/queries.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from slpkg.utilities import Utilities -from slpkg.models.models import BinariesTable -from slpkg.models.models import session as Session - - -class BinQueries: - """ Queries class for the binary repositories. """ - - def __init__(self, repository: str): - self.repository: str = repository - self.session = Session - - self.utils = Utilities() - - def repository_data(self) -> dict: - """ Returns a dictionary with the repository data. """ - repository_data: tuple = self.session.query( - BinariesTable).where( - BinariesTable.repo == self.repository).all() - - repos_dict: dict = { - data.name: {'version': data.version, - 'package': data.package, - 'mirror': data.mirror, - 'location': data.location, - 'size_comp': data.size_comp, - 'size_uncomp': data.size_uncomp, - 'requires': data.required, - 'conflicts': data.conflicts, - 'suggests': data.suggests, - 'description': data.description, - 'checksum': data.checksum, - 'repository': data.repo} - for data in repository_data - if not self.utils.blacklist_pattern(data.name) - } - - return repos_dict diff --git a/slpkg/checks.py b/slpkg/checks.py index cdd7f0cf..0a2dce15 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -5,7 +5,6 @@ from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.error_messages import Errors from slpkg.repositories import Repositories -from slpkg.models.models import session as Session # from slpkg.models.models import SBoTable, PonceTable, BinariesTable @@ -21,7 +20,6 @@ class Check(Configs): self.utils = Utilities() self.repos = Repositories() - self.session = Session self.count_rows: int = 0 self.is_binary: bool = self.utils.is_binary_repo(repository) diff --git a/slpkg/cleanings.py b/slpkg/cleanings.py index 69902cc7..e629bc53 100644 --- a/slpkg/cleanings.py +++ b/slpkg/cleanings.py @@ -8,10 +8,6 @@ from slpkg.configs import Configs from slpkg.utilities import Utilities 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, - SBoTable, PonceTable, BinariesTable, - LastRepoUpdated) class Cleanings(Configs): diff --git a/slpkg/download_only.py b/slpkg/download_only.py index b95a30c5..20c542c3 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -10,7 +10,6 @@ from slpkg.utilities import Utilities from slpkg.downloader import Downloader from slpkg.views.views import View from slpkg.repositories import Repositories -from slpkg.models.models import session as Session class DownloadOnly(Configs): @@ -29,7 +28,6 @@ class DownloadOnly(Configs): self.download = Downloader(flags) self.repos = Repositories() self.utils = Utilities() - self.session = Session self.urls: dict = {} self.download_path: Path = Path() diff --git a/slpkg/logging_deps.py b/slpkg/logging_deps.py index aa8fe2dc..61eacc09 100644 --- a/slpkg/logging_deps.py +++ b/slpkg/logging_deps.py @@ -4,8 +4,6 @@ from slpkg.utilities import Utilities from slpkg.binaries.required import Required from slpkg.sbos.dependencies import Requires -from slpkg.models.models import LogsDependencies -from slpkg.models.models import session as Session class LoggingDeps: @@ -15,7 +13,6 @@ class LoggingDeps: self.data: dict = data self.utils = Utilities() - self.session = Session self.is_binary: bool = self.utils.is_binary_repo(repository) diff --git a/slpkg/models/__init__.py b/slpkg/models/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/slpkg/models/models.py b/slpkg/models/models.py deleted file mode 100644 index 85ec26b6..00000000 --- a/slpkg/models/models.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -import os - -from dataclasses import dataclass -from sqlalchemy.orm import sessionmaker -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy import create_engine, Column, Integer, Text - -from slpkg.configs import Configs - - -DATABASE_URI: str = os.path.join(f'sqlite:///{Configs.db_path}', Configs.database_name) -engine = create_engine(DATABASE_URI) -session = sessionmaker(engine)() -Base = declarative_base() - - -@dataclass -class SBoTable(Base): - """ The main table for the SBo repository. """ - - __tablename__ = 'sbotable' - - 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 -class PonceTable(Base): - """ The main table for the ponce repository. """ - - __tablename__: str = 'poncetable' - - 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 -class BinariesTable(Base): - """ The main table for the binary repositories. """ - - __tablename__: str = 'binariestable' - - 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) - required: str = Column(Text) - conflicts: str = Column(Text) - suggests: str = Column(Text) - description: str = Column(Text) - checksum: str = Column(Text) - - -@dataclass -class LogsDependencies(Base): - """ The table that stores the dependencies after installing a package. """ - - __tablename__: str = 'logsdependencies' - - id: int = Column(Integer, primary_key=True) - name: str = Column(Text) - requires: str = Column(Text) - - -@dataclass -class LastRepoUpdated(Base): - """ The table that saves the last updated date. """ - - __tablename__: str = 'lastupdated' - - id: int = Column(Integer, primary_key=True) - repo: str = Column(Text) - date: str = Column(Text) - - -Base.metadata.create_all(engine) diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index cee7b1fc..6d2c2347 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -10,8 +10,6 @@ from slpkg.dialog_box import DialogBox from slpkg.views.views import View from slpkg.views.asciibox import AsciiBox from slpkg.multi_process import MultiProcess -from slpkg.models.models import LogsDependencies -from slpkg.models.models import session as Session class RemovePackages(Configs): @@ -23,7 +21,6 @@ class RemovePackages(Configs): super(Configs, self).__init__() self.packages: list = packages - self.session = Session self.dialogbox = DialogBox() self.utils = Utilities() self.ascii = AsciiBox() diff --git a/slpkg/repo_info.py b/slpkg/repo_info.py index 8a989096..5daa808d 100644 --- a/slpkg/repo_info.py +++ b/slpkg/repo_info.py @@ -6,9 +6,6 @@ import shutil from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.repositories import Repositories -from slpkg.models.models import session as Session -from slpkg.models.models import (LastRepoUpdated, SBoTable, - PonceTable, BinariesTable) class RepoInfo(Configs): @@ -18,7 +15,6 @@ class RepoInfo(Configs): self.flags: list = flags self.repository: str = repository - self.session = Session self.utils = Utilities() self.repos = Repositories() self.columns, self.rows = shutil.get_terminal_size() diff --git a/slpkg/sbos/queries.py b/slpkg/sbos/queries.py deleted file mode 100644 index d6ae8d68..00000000 --- a/slpkg/sbos/queries.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from slpkg.configs import Configs -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 - - -class SBoQueries(Configs): - """ Queries class for the sbo repository. """ - - def __init__(self, repository: str): - super(Configs, self).__init__() - self.session = Session - - self.repos = Repositories() - self.utils = Utilities() - - table: dict = { - self.repos.sbo_repo_name: SBoTable, - self.repos.ponce_repo_name: PonceTable - } - - if repository == '*': - repository = self.repos.default_repository - - self.sbo_table: str = table[repository] - - def repository_data(self) -> dict: - """ Returns a dictionary with the repository data. """ - repository_data: tuple = self.session.query(self.sbo_table).all() - - repos_dict: dict = { - data.name: {'location': data.location, - 'files': data.files, - 'version': data.version, - 'download': data.download, - 'download64': data.download64, - 'md5sum': data.md5sum, - 'md5sum64': data.md5sum64, - 'requires': data.requires, - 'description': data.short_description} - for data in repository_data - if not self.utils.blacklist_pattern(data.name) - } - return repos_dict diff --git a/slpkg/search.py b/slpkg/search.py index 5a1f448f..373fba9f 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -4,9 +4,7 @@ from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.views.asciibox import AsciiBox -from slpkg.sbos.queries import SBoQueries from slpkg.repositories import Repositories -from slpkg.binaries.queries import BinQueries class SearchPackage(Configs):