From 1b69429f6487981656305fd2c1cdfe968ab78ab6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 17:36:00 +0200 Subject: [PATCH 01/17] Fixed code style Signed-off-by: Dimitris Zlatanidis --- requirements.txt | 1 + slpkg/blacklist.py | 4 +- slpkg/check_updates.py | 4 +- slpkg/checks.py | 20 +++++----- slpkg/checksum.py | 9 +++-- slpkg/clean_logs.py | 8 ++-- slpkg/configs.py | 34 ++++++++-------- slpkg/create_data.py | 9 +++-- slpkg/dependencies.py | 4 +- slpkg/download_only.py | 6 +-- slpkg/downloader.py | 2 +- slpkg/find_installed.py | 6 +-- slpkg/main.py | 25 ++++++------ slpkg/models/models.py | 4 +- slpkg/queries.py | 6 +-- slpkg/remove_packages.py | 21 +++++----- slpkg/search.py | 8 ++-- slpkg/slackbuild.py | 53 ++++++++++++------------- slpkg/update_repository.py | 9 +++-- slpkg/upgrade.py | 9 ++--- slpkg/utilities.py | 34 +++++++++------- slpkg/views/cli_menu.py | 78 ++++++++++++++++++------------------- slpkg/views/version.py | 2 +- slpkg/views/view_package.py | 54 ++++++++++++------------- slpkg/views/views.py | 60 +++++++++++++++------------- 25 files changed, 242 insertions(+), 228 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6523a208..90355720 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ SQLAlchemy>=1.4.36 toml>=0.10.2 +setuptools~=60.2.0 diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index bc53e3ce..20586e07 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -9,10 +9,10 @@ from slpkg.configs import Configs class Blacklist: - ''' Reads and returns the blacklist. ''' + """ Reads and returns the blacklist. """ def __init__(self): - self.configs: str = Configs + self.configs = Configs def get(self): file = f'{self.configs.etc_path}/blacklist.toml' diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 4986422f..2ee72212 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -9,10 +9,10 @@ from slpkg.configs import Configs class CheckUpdates: - ''' Check for changes in the ChangeLog file. ''' + """ Check for changes in the ChangeLog file. """ def __init__(self): - self.configs: str = Configs + self.configs = Configs def updates(self): local_date = 0 diff --git a/slpkg/checks.py b/slpkg/checks.py index e786bb6a..63d0f34e 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -9,13 +9,14 @@ from slpkg.blacklist import Blacklist class Check: - ''' Some checks before proceed. ''' + """ Some checks before proceed. """ def __init__(self): - self.configs: str = Configs + self.configs = Configs - def exists(self, slackbuilds: list): - ''' Checking if the slackbuild exists in the repository. ''' + @staticmethod + def exists(slackbuilds: list): + """ Checking if the slackbuild exists in the repository. """ packages = [] for sbo in slackbuilds: @@ -26,8 +27,9 @@ class Check: raise SystemExit(f'\nPackages \'{", ".join(packages)}\' ' 'does not exists.\n') - def unsupported(self, slackbuilds: list): - ''' Checking for unsupported slackbuilds. ''' + @staticmethod + def unsupported(slackbuilds: list): + """ Checking for unsupported slackbuilds. """ for sbo in slackbuilds: sources = SBoQueries(sbo).sources() @@ -35,7 +37,7 @@ class Check: raise SystemExit(f"\nPackage '{sbo}' unsupported by arch.\n") def installed(self, slackbuilds: list): - ''' Checking for installed packages. ''' + """ Checking for installed packages. """ found, not_found = [], [] for sbo in slackbuilds: @@ -55,7 +57,7 @@ class Check: return found def blacklist(self, slackbuilds: list): - ''' Checking if the packages are blacklisted. ''' + """ Checking if the packages are blacklisted. """ packages = [] black = Blacklist() @@ -70,7 +72,7 @@ class Check: f'{self.configs.etc_path} folder.\n') def database(self): - ''' Checking for empty table ''' + """ Checking for empty table """ db = f'{self.configs.db_path}/{self.configs.database}' if not SBoQueries('').names() or not os.path.isfile(db): raise SystemExit('\nYou need to update the package lists first.\n' diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 33b9d560..38c99be5 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -8,10 +8,10 @@ from slpkg.views.views import ViewMessage class Md5sum: - ''' Checksum the sources. ''' + """ Checksum the sources. """ def __init__(self, flags): - self.flags: str = flags + self.flags = flags def check(self, path: str, source: str, checksum: str, name: str): filename = f'{path}/{source.split("/")[-1]}' @@ -26,8 +26,9 @@ class Md5sum: print(f'\nMD5SUM check for {name} FAILED.') view = ViewMessage() - view.question(self.flags) + view.question() - def read_file(self, filename: str): + @staticmethod + def read_file(filename: str): with open(filename, 'rb') as f: return f.read() diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py index 724b22e5..47a44c63 100644 --- a/slpkg/clean_logs.py +++ b/slpkg/clean_logs.py @@ -8,18 +8,18 @@ from slpkg.models.models import session as Session class CleanLogsDependencies: - ''' Cleans the logs from packages. ''' + """ Cleans the logs from packages. """ def __init__(self, flags): - self.flags: str = flags - self.session: str = Session + self.flags = flags + self.session = Session def clean(self): dependencies = self.session.query( LogsDependencies.name, LogsDependencies.requires).all() if dependencies: - view = ViewMessage(self.flags) + view = ViewMessage() view.logs_packages(dependencies) view.question() diff --git a/slpkg/configs.py b/slpkg/configs.py index f1d6b777..94cd6a89 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -11,11 +11,11 @@ from dataclasses import dataclass @dataclass class Configs: + """ Default configurations. """ # Programme name prog_name: str = 'slpkg' - ''' Default configurations. ''' # OS architecture by default os_arch: str = platform.machine() @@ -109,26 +109,26 @@ class Configs: @classmethod def colour(cls): color = { - 'BOLD': '', - 'RED': '', - 'GREEN': '', - 'YELLOW': '', - 'CYAN': '', - 'BLUE': '', - 'GREY': '', - 'ENDC': '' + 'bold': '', + 'red': '', + 'green': '', + 'yellow': '', + 'cyan': '', + 'blue': '', + 'grey': '', + 'endc': '' } if cls.colors: color = { - 'BOLD': '\033[1m', - 'RED': '\x1b[91m', - 'GREEN': '\x1b[32m', - 'YELLOW': '\x1b[93m', - 'CYAN': '\x1b[96m', - 'BLUE': '\x1b[94m', - 'GREY': '\x1b[38;5;247m', - 'ENDC': '\x1b[0m' + 'bold': '\033[1m', + 'red': '\x1b[91m', + 'green': '\x1b[32m', + 'yellow': '\x1b[93m', + 'cyan': '\x1b[96m', + 'blue': '\x1b[94m', + 'grey': '\x1b[38;5;247m', + 'endc': '\x1b[0m' } return color diff --git a/slpkg/create_data.py b/slpkg/create_data.py index d77e9dc5..deace01d 100644 --- a/slpkg/create_data.py +++ b/slpkg/create_data.py @@ -8,11 +8,11 @@ from slpkg.models.models import session as Session class CreateData: - ''' Reads the SLACKBUILDS.TXT file and inserts them into the database. ''' + """ Reads the SLACKBUILDS.TXT file and inserts them into the database. """ def __init__(self): - self.configs: str = Configs - self.session: str = Session + self.configs = Configs + self.session = Session def insert_sbo_table(self): sbo_tags = [ @@ -56,6 +56,7 @@ class CreateData: self.session.commit() - def read_file(self, file: str): + @staticmethod + def read_file(file: str): with open(file, 'r', encoding='utf-8') as f: return f.readlines() diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py index fbd20672..e0874231 100644 --- a/slpkg/dependencies.py +++ b/slpkg/dependencies.py @@ -6,8 +6,8 @@ from slpkg.queries import SBoQueries class Requires: - ''' Creates a list of dependencies with - the right order to install. ''' + """ Creates a list of dependencies with + the right order to install. """ def __init__(self, name): self.name: str = name diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 76b0a48f..17a25b09 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -10,12 +10,12 @@ from slpkg.models.models import session as Session class Download: - ''' Download the slackbuilds with the sources only. ''' + """ Download the slackbuilds with the sources only. """ def __init__(self, flags): self.flags: list = flags - self.configs: str = Configs - self.session: str = Session + self.configs = Configs + self.session = Session def packages(self, slackbuilds: list): view = ViewMessage(self.flags) diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 75881ab2..7a09df6a 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -8,7 +8,7 @@ from slpkg.configs import Configs class Wget: - ''' Wget donwloader. ''' + """ Wget donwloader. """ def __init__(self): self.wget_options: str = Configs.wget_options diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index 584df426..7ca98fda 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -8,10 +8,10 @@ from slpkg.configs import Configs class FindInstalled: - ''' Find installed packages. ''' + """ Find installed packages. """ def __init__(self): - self.configs: str = Configs + self.configs = Configs colors = self.configs.colour self.color = colors() @@ -30,6 +30,6 @@ class FindInstalled: def matched(self, matching: list): if matching: for package in matching: - print(f'{self.color["CYAN"]}{package}{self.color["ENDC"]}') + print(f'{self.color["cyan"]}{package}{self.color["endc"]}') else: print('\nDoes not match any package.\n') diff --git a/slpkg/main.py b/slpkg/main.py index f91eaa4a..743d9f96 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -26,25 +26,24 @@ class Argparse: def __init__(self, args): self.args: list = args - self.configs = Configs - self.usage = Usage() - self.flag() - self.check = Check() - - if len(self.args) == 0: - self.usage.help_short() - - self.check.blacklist(self.args) - - def flag(self): - self.flags = [] - self.options = ['--yes', '--jobs', '--resolve-off', '--reinstall', '--skip-installed'] + if len(self.args) == 0: + self.usage.help_short() + + self.flags = [] + self.configs = Configs + self.usage = Usage() + self.flag() + self.check = Check() + + self.check.blacklist(self.args) + + def flag(self): for option in self.options: if option in self.args: self.args.remove(option) diff --git a/slpkg/models/models.py b/slpkg/models/models.py index c571f9c7..9beda31f 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -22,7 +22,7 @@ Base = declarative_base() @dataclass class SBoTable(Base): - ''' The main table for the SBo repository. ''' + """ The main table for the SBo repository. """ __tablename__ = 'sbotable' @@ -41,7 +41,7 @@ class SBoTable(Base): @dataclass class LogsDependencies(Base): - ''' The table that stores the dependencies after installing a package. ''' + """ The table that stores the dependencies after installing a package. """ __tablename__ = 'logsdependencies' diff --git a/slpkg/queries.py b/slpkg/queries.py index 95aa3cc7..98c72459 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -12,9 +12,9 @@ class SBoQueries: ''' Queries class for the sbo repository. ''' def __init__(self, name): - self.name: str = name - self.session: str = Session - self.configs: str = Configs + self.name = name + self.session = Session + self.configs = Configs self.black = Blacklist() if self.name in self.black.get(): diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index 0208a22a..311f81b0 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -11,19 +11,18 @@ from slpkg.models.models import session as Session class RemovePackages: - ''' Removes installed packages. ''' + """ Removes installed packages. """ def __init__(self, packages, flags): - self.packages: str = packages - self.flags: list = flags - self.session: str = Session - self.configs: str = Configs - - def remove(self): - ''' Removes package with dependencies. ''' + self.packages = packages + self.flags = flags + self.session = Session + self.configs = Configs self.installed_packages = [] self.dependencies = [] + def remove(self): + """ Removes package with dependencies. """ view = ViewMessage(self.flags) self.installed_packages, self.dependencies = view.remove_packages( @@ -38,20 +37,20 @@ class RemovePackages: self.delete_deps_logs() def remove_packages(self): - ''' Run Slackware command to remove the packages. ''' + """ Run Slackware command to remove the packages. """ for package in self.installed_packages: command = f'{self.configs.removepkg} {package}' subprocess.call(command, shell=True) def delete_main_logs(self): - ''' Deletes main packages from logs. ''' + """ Deletes main packages from logs. """ for pkg in self.packages: self.session.query(LogsDependencies).filter( LogsDependencies.name == pkg).delete() self.session.commit() def delete_deps_logs(self): - ''' Deletes depends packages from logs. ''' + """ Deletes depends packages from logs. """ for pkg in self.dependencies[0].split(): self.session.query(LogsDependencies).filter( LogsDependencies.name == pkg).delete() diff --git a/slpkg/search.py b/slpkg/search.py index bf66e9f2..9fdc498b 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -7,15 +7,15 @@ from slpkg.configs import Configs class SearchPackage: - ''' Search slackbuilds from the repository. ''' + """ Search slackbuilds from the repository. """ def __init__(self): self.colors: dict = Configs.colour def package(self, packages): color = self.colors() - CYAN = color['CYAN'] - ENDC = color['ENDC'] + cyan = color['cyan'] + endc = color['endc'] matching = 0 names = SBoQueries('').names() @@ -29,6 +29,6 @@ class SearchPackage: matching += 1 desc = SBoQueries(name).description().replace(name, '') print(f'{name}-{SBoQueries(name).version()}' - f'{CYAN}{desc}{ENDC}') + f'{cyan}{desc}{endc}') if not matching: print('\nDoes not match any package.\n') diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index f71c870f..f4e01ac7 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -19,20 +19,21 @@ from slpkg.models.models import session as Session class Slackbuilds: - ''' Download build and install the SlackBuilds. ''' + """ Download build and install the SlackBuilds. """ def __init__(self, slackbuilds, flags, install): - self.slackbuilds: str = slackbuilds - self.flags: list = flags - self.install: bool = install - self.session: str = Session - self.utils: str = Utilities() - self.configs: str = Configs - - def execute(self): - ''' Starting build or install the slackbuilds. ''' + self.slackbuilds = slackbuilds + self.flags = flags + self.install = install + self.session = Session + self.utils = Utilities() + self.configs = Configs self.install_order = [] self.dependencies = [] + self.sbos = {} + + def execute(self): + """ Starting build or install the slackbuilds. """ self.creating_dictionary() if '--resolve-off' not in self.flags: @@ -44,7 +45,7 @@ class Slackbuilds: self.download_slackbuilds_and_build() def view_before_build(self): - ''' View slackbuilds before proceed. ''' + """ View slackbuilds before proceed. """ view = ViewMessage(self.flags) if self.install: @@ -57,13 +58,12 @@ class Slackbuilds: view.question() def creating_dictionary(self): - ''' Dictionary with the main slackbuilds and dependencies. ''' - self.sbos = {} + """ Dictionary with the main slackbuilds and dependencies. """ for sbo in self.slackbuilds: self.sbos[sbo] = Requires(sbo).resolve() def creating_dependencies_for_build(self): - ''' List with the dependencies. ''' + """ List with the dependencies. """ for deps in self.sbos.values(): for dep in deps: @@ -80,11 +80,11 @@ class Slackbuilds: self.install_order.extend(self.dependencies) def creating_main_for_build(self): - ''' List with the main slackbuilds. ''' + """ List with the main slackbuilds. """ [self.install_order.append(main) for main in self.sbos.keys()] def download_slackbuilds_and_build(self): - ''' Downloads files and sources and starting the build. ''' + """ Downloads files and sources and starting the build. """ wget = Wget() for sbo in self.install_order: @@ -116,7 +116,7 @@ class Slackbuilds: self.logging_installed_dependencies(sbo) def patch_sbo_tag(self, sbo): - ''' Patching SBo TAG from the configuration file. ''' + """ Patching SBo TAG from the configuration file. """ sbo_script = f'{self.configs.build_path}/{sbo}/{sbo}.SlackBuild' if os.path.isfile(sbo_script): @@ -130,7 +130,7 @@ class Slackbuilds: script.write(line) def logging_installed_dependencies(self, name: str): - ''' Logging installed dependencies and used for remove. ''' + """ Logging installed dependencies and used for remove. """ exist = self.session.query(LogsDependencies.name).filter( LogsDependencies.name == name).first() @@ -149,19 +149,19 @@ class Slackbuilds: self.session.commit() def install_package(self, package: str): - ''' Install the packages that before created in the tmp directory. ''' + """ Install the packages that before created in the tmp directory. """ execute = self.configs.installpkg if ('--reinstall' in self.flags and self.utils.is_installed(package[:-4])): - execute = self.reinstall + execute = self.configs.reinstall command = f'{execute} {self.configs.tmp_path}/{package}' subprocess.call(command, shell=True) def creating_package_for_install(self, name: str): - ''' Creating a list with all the finished packages for + """ Creating a list with all the finished packages for installation. - ''' + """ version = SBoQueries(name).version() packages = [] @@ -174,7 +174,7 @@ class Slackbuilds: return max(packages) def build_the_script(self, path: str, name: str): - ''' Run the .SlackBuild script. ''' + """ Run the .SlackBuild script. """ folder = f'{path}/{name}/' slackbuild = f'./{name}.SlackBuild' execute = folder + slackbuild @@ -187,13 +187,14 @@ class Slackbuilds: if stdout > 0: raise SystemExit(stdout) - def set_makeflags(self): - ''' Set number of processors. ''' + @staticmethod + def set_makeflags(): + """ Set number of processors. """ cpus = multiprocessing.cpu_count() os.environ['MAKEFLAGS'] = f'-j {cpus}' def download_sources(self, name: str, sources: str): - ''' Download the sources. ''' + """ Download the sources. """ wget = Wget() path = f'{self.configs.build_path}/{name}' diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index daf1da04..92df2133 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -14,11 +14,11 @@ from slpkg.models.models import session as Session class UpdateRepository: - ''' Deletes and install the data. ''' + """ Deletes and install the data. """ def __init__(self): - self.configs: str = Configs - self.session: str = Session + self.configs = Configs + self.session = Session def sbo(self): print('Updating the package list...\n') @@ -36,7 +36,8 @@ class UpdateRepository: data = CreateData() data.insert_sbo_table() - def delete_file(self, dir: str, txt_file: str): + @staticmethod + def delete_file(dir: str, txt_file: str): file = f'{dir}/{txt_file}' if path.exists(file): os.remove(file) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index b7f1f269..c951bba4 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -10,13 +10,13 @@ from slpkg.blacklist import Blacklist class Upgrade: - ''' Upgrade the installed packages. ''' + """ Upgrade the installed packages. """ def __init__(self): - self.configs: str = Configs + self.configs = Configs def packages(self): - ''' Compares version of packages and returns the maximum. ''' + """ Compares version of packages and returns the maximum. """ print("Do not forget to run 'slpkg update' before.") repo_packages = SBoQueries('').names() @@ -28,8 +28,7 @@ class Upgrade: and inst_pkg_name not in black): if inst_pkg_name in repo_packages: - installed_ver = pkg.replace(f'{inst_pkg_name}-', - '').split('-')[0] + installed_ver = pkg.replace(f'{inst_pkg_name}-', '').split('-')[0] repo_ver = SBoQueries(inst_pkg_name).version() if LooseVersion(repo_ver) > LooseVersion(installed_ver): diff --git a/slpkg/utilities.py b/slpkg/utilities.py index ce1ed960..88932102 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -13,35 +13,39 @@ from slpkg.configs import Configs class Utilities: def __init__(self): - self.configs: str = Configs + self.configs = Configs - def untar_archive(self, path: str, archive: str, ext_path: str): - ''' Untar the file to the build folder. ''' + def is_installed(self, package: str): + """ Returns True if a package is installed. """ + for pkg in os.listdir(self.configs.log_packages): + if package in pkg: + return pkg + + @staticmethod + def untar_archive(path: str, archive: str, ext_path: str): + """ Untar the file to the build folder. """ tar_file = f'{path}/{archive}' untar = tarfile.open(tar_file) untar.extractall(ext_path) untar.close() - def is_installed(self, package: str): - ''' Returns True if a package is installed. ''' - for pkg in os.listdir(self.configs.log_packages): - if package in pkg: - return pkg - - def remove_file_if_exists(self, path: str, file: str): - ''' Clean the the old files. ''' + @staticmethod + def remove_file_if_exists(path: str, file: str): + """ Clean the the old files. """ archive = f'{path}/{file}' if os.path.isfile(archive): os.remove(archive) - def remove_folder_if_exists(self, path: str, folder: str): - ''' Clean the the old folders. ''' + @staticmethod + def remove_folder_if_exists(path: str, folder: str): + """ Clean the the old folders. """ directory = f'{path}/{folder}' if os.path.isdir(directory): shutil.rmtree(directory) - def create_folder(self, path: str, folder: str): - ''' Creates folder. ''' + @staticmethod + def create_folder(path: str, folder: str): + """ Creates folder. """ directory = f'{path}/{folder}' if not os.path.isdir(directory): os.makedirs(directory) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index c2e816fc..445a7367 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -11,52 +11,52 @@ class Usage: colors = Configs.colour color = colors() - self.BOLD = color['BOLD'] - self.RED = color['RED'] - self.CYAN = color['CYAN'] - self.YELLOW = color['YELLOW'] - self.ENDC = color['ENDC'] - + self.bold = color['bold'] + self.red = color['red'] + self.cyan = color['cyan'] + self.yellow = color['yellow'] + self.endc = color['endc'] def help_short(self): - args = (f'Usage: {Configs.prog_name} [{self.YELLOW}OPTIONS{self.ENDC}] [{self.CYAN}COMMAND{self.ENDC}] \n' - f'\n slpkg [{self.YELLOW}OPTIONS{self.ENDC}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n' - f' slpkg [{self.CYAN}COMMAND{self.ENDC}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n' - f' slpkg [{self.CYAN}COMMAND{self.ENDC}] [-b, build, -i, install, -d, download] \n' - f' slpkg [{self.CYAN}COMMAND{self.ENDC}] [-r, remove, -f, find, -w, view, -s, search] \n' - " \nIf you need more information please try 'slpkg --help'.") + args = ( + f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n' + f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [update, upgrade, check-updates, clean-logs, clean-tmp]\n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] \n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-r, remove, -f, find, -w, view, -s, search] \n' + " \nIf you need more information please try 'slpkg --help'.") print(args) raise SystemExit() - def help(self, status: int): - args = [f'{self.BOLD}USAGE:{self.ENDC} {Configs.prog_name} [{self.YELLOW}OPTIONS{self.ENDC}] [{self.CYAN}COMMAND{self.ENDC}] \n', - f'{self.BOLD}DESCRIPTION:{self.ENDC}', - ' Packaging tool that interacts with the SBo repository.\n', - f'{self.BOLD}COMMANDS:{self.ENDC}', - f' {self.RED}update{self.ENDC} Update the package lists.', - f' {self.CYAN}upgrade{self.ENDC} Upgrade all the packages.', - f' {self.CYAN}check-updates{self.ENDC} Check for news on ChangeLog.txt.', - f' {self.CYAN}clean-logs{self.ENDC} Clean dependencies log tracking.', - f' {self.CYAN}clean-tmp{self.ENDC} Delete all the downloaded sources.', - f' {self.CYAN}-b, build{self.ENDC} Build only the packages.', - f' {self.CYAN}-i, install{self.ENDC} Build and install the packages.', - f' {self.CYAN}-d, download{self.ENDC} Download only the scripts and sources.', - f' {self.CYAN}-r, remove{self.ENDC} Remove installed packages.', - f' {self.CYAN}-f, find{self.ENDC} Find installed packages.', - f' {self.CYAN}-w, view{self.ENDC} View packages from the repository.', - f' {self.CYAN}-s, search{self.ENDC} Search packages from the repository.\n', - f'{self.BOLD}OPTIONS:{self.ENDC}', - f' {self.YELLOW}--yes{self.ENDC} Answer Yes to all questions.', - f' {self.YELLOW}--jobs{self.ENDC} Set it for multicore systems.', - f' {self.YELLOW}--resolve-off{self.ENDC} Turns off dependency resolving.', - f' {self.YELLOW}--reinstall{self.ENDC} Upgrade packages of the same version.', - f' {self.YELLOW}--skip-installed{self.ENDC} Skip installed packages.\n', - ' -h, --help Show this message and exit.', - ' -v, --version Print version and exit.\n', - 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', - 'If you need more information try to use slpkg manpage.'] + args = [ + f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n', + f'{self.bold}DESCRIPTION:{self.endc}', + ' Packaging tool that interacts with the SBo repository.\n', + f'{self.bold}COMMANDS:{self.endc}', + f' {self.red}update{self.endc} Update the package lists.', + f' {self.cyan}upgrade{self.endc} Upgrade all the packages.', + f' {self.cyan}check-updates{self.endc} Check for news on ChangeLog.txt.', + f' {self.cyan}clean-logs{self.endc} Clean dependencies log tracking.', + f' {self.cyan}clean-tmp{self.endc} Delete all the downloaded sources.', + f' {self.cyan}-b, build{self.endc} Build only the packages.', + f' {self.cyan}-i, install{self.endc} Build and install the packages.', + f' {self.cyan}-d, download{self.endc} Download only the scripts and sources.', + f' {self.cyan}-r, remove{self.endc} Remove installed packages.', + f' {self.cyan}-f, find{self.endc} Find installed packages.', + f' {self.cyan}-w, view{self.endc} View packages from the repository.', + f' {self.cyan}-s, search{self.endc} Search packages from the repository.\n', + f'{self.bold}OPTIONS:{self.endc}', + f' {self.yellow}--yes{self.endc} Answer Yes to all questions.', + f' {self.yellow}--jobs{self.endc} Set it for multicore systems.', + f' {self.yellow}--resolve-off{self.endc} Turns off dependency resolving.', + f' {self.yellow}--reinstall{self.endc} Upgrade packages of the same version.', + f' {self.yellow}--skip-installed{self.endc} Skip installed packages.\n', + ' -h, --help Show this message and exit.', + ' -v, --version Print version and exit.\n', + 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', + 'If you need more information try to use slpkg manpage.'] for opt in args: print(opt) diff --git a/slpkg/views/version.py b/slpkg/views/version.py index 3f6c5580..0e9da945 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -3,7 +3,7 @@ class Version: - ''' Print the vesrsion. ''' + """ Print the vesrsion. """ def __init__(self): self.version_info: tuple = (4, 3, 4) diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index ec11c055..6c0ad5eb 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -11,22 +11,22 @@ from slpkg.models.models import session as Session class ViewPackage: - ''' View the repository packages. ''' + """ View the repository packages. """ def __init__(self): - self.session: str = Session - self.configs: str = Configs - self.colors: dict = self.configs.colour + self.session = Session + self.configs = Configs + self.colors = self.configs.colour def package(self, packages): http = urllib3.PoolManager() color = self.colors() - GREEN = color['GREEN'] - BLUE = color['BLUE'] - YELLOW = color['YELLOW'] - CYAN = color['CYAN'] - RED = color['RED'] - ENDC = color['ENDC'] + green = color['green'] + blue = color['blue'] + yellow = color['yellow'] + cyan = color['cyan'] + red = color['red'] + endc = color['endc'] for package in packages: info = self.session.query( @@ -59,20 +59,20 @@ class ViewPackage: deps = (', '.join([f'{pkg} ({SBoQueries(pkg).version()})' for pkg in info[2].split()])) - print(f'Name: {GREEN}{info[0]}{ENDC}\n' - f'Version: {GREEN}{info[1]}{ENDC}\n' - f'Requires: {GREEN}{deps}{ENDC}\n' - f'Homepage: {BLUE}{homepage}{ENDC}\n' - f'Download SlackBuild: {BLUE}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{self.configs.sbo_tar_suffix}{ENDC}\n' - f'Download sources: {BLUE}{info[3]}{ENDC}\n' - f'Download_x86_64 sources: {BLUE}{info[4]}{ENDC}\n' - f'Md5sum: {YELLOW}{info[5]}{ENDC}\n' - f'Md5sum_x86_64: {YELLOW}{info[6]}{ENDC}\n' - f'Files: {GREEN}{info[7]}{ENDC}\n' - f'Description: {GREEN}{info[8]}{ENDC}\n' - f'Slackware: {CYAN}{self.configs.sbo_repo_url.split("/")[-1]}{ENDC}\n' - f'Category: {RED}{info[9]}{ENDC}\n' - f'SBo url: {BLUE}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{ENDC}\n' - f'Maintainer: {YELLOW}{maintainer}{ENDC}\n' - f'Email: {YELLOW}{email}{ENDC}\n' - f'\nREADME: {CYAN}{readme.data.decode()}{ENDC}') + print(f'Name: {green}{info[0]}{endc}\n' + f'Version: {green}{info[1]}{endc}\n' + f'Requires: {green}{deps}{endc}\n' + f'Homepage: {blue}{homepage}{endc}\n' + f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{self.configs.sbo_tar_suffix}{endc}\n' + f'Download sources: {blue}{info[3]}{endc}\n' + f'Download_x86_64 sources: {blue}{info[4]}{endc}\n' + f'Md5sum: {yellow}{info[5]}{endc}\n' + f'Md5sum_x86_64: {yellow}{info[6]}{endc}\n' + f'Files: {green}{info[7]}{endc}\n' + f'Description: {green}{info[8]}{endc}\n' + f'Slackware: {cyan}{self.configs.sbo_repo_url.split("/")[-1]}{endc}\n' + f'Category: {red}{info[9]}{endc}\n' + f'SBo url: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{endc}\n' + f'Maintainer: {yellow}{maintainer}{endc}\n' + f'Email: {yellow}{email}{endc}\n' + f'\nREADME: {cyan}{readme.data.decode()}{endc}') diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 842c36b0..d72402bd 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -12,15 +12,16 @@ from slpkg.models.models import session as Session class ViewMessage: - ''' Print some messages before. ''' + """ Print some messages before. """ def __init__(self, flags): - self.flags: list = flags - self.configs: str = Configs - self.colors: dict = self.configs.colour - self.session: str = Session - self.utils: str = Utilities() - self.black: list = Blacklist() + self.flags = flags + self.configs = Configs + self.colors = self.configs.colour + self.session = Session + self.utils = Utilities() + self.black = Blacklist() + self.installed_packages = [] def build_packages(self, slackbuilds: list, dependencies: list): print('The following packages will be build:\n') @@ -53,6 +54,7 @@ class ViewMessage: self._view_total(slackbuilds, dependencies, option='install') def download_packages(self, slackbuilds: list): + """ View downloaded packages. """ print('The following packages will be downloaded:\n') for sbo in slackbuilds: @@ -60,8 +62,8 @@ class ViewMessage: self._view_download(sbo, version) def remove_packages(self, packages: list): + """ View remove packages. """ print('The following packages will be removed:\n') - self.installed_packages = [] slackbuilds, dependencies, deps = [], [], [] for pkg in packages: @@ -88,33 +90,36 @@ class ViewMessage: return self.installed_packages, dependencies def _view_download(self, sbo: str, version: str): + """ View packages for download only. """ color = self.colors() if self.utils.is_installed(f'{sbo}-'): - print(f'[{color["YELLOW"]} download {color["ENDC"]}] -> ' + print(f'[{color["yellow"]} download {color["endc"]}] -> ' f'{sbo}-{version}') else: - print(f'[{color["CYAN"]} download {color["ENDC"]}] -> ' + print(f'[{color["cyan"]} download {color["endc"]}] -> ' f'{sbo}-{version}') def _view_build(self, sbo: str, version: str): + """ View packages for build. """ color = self.colors() if self.utils.is_installed(f'{sbo}-'): - print(f'[{color["YELLOW"]} build {color["ENDC"]}] -> ' + print(f'[{color["yellow"]} build {color["endc"]}] -> ' f'{sbo}-{version}') else: - print(f'[{color["CYAN"]} build {color["ENDC"]}] -> ' + print(f'[{color["cyan"]} build {color["endc"]}] -> ' f'{sbo}-{version}') def _view_install(self, sbo: str, version: str): + """ View the packages for install. """ color = self.colors() installed = self.utils.is_installed(f'{sbo}-') - install, set_color = 'install', color['RED'] + install, set_color = 'install', color['red'] if '--reinstall' in self.flags: - install, set_color = 'upgrade', color['YELLOW'] + install, set_color = 'upgrade', color['yellow'] if installed and 'noarch' in installed: self.configs.os_arch = 'noarch' @@ -124,16 +129,16 @@ class ViewMessage: if '--reinstall' not in self.flags: install = 'installed' - print(f'[{set_color} {install} {color["ENDC"]}] -> ' + print(f'[{set_color} {install} {color["endc"]}] -> ' f'{sbo}-{version} {set_color}' f'({installed.split(self.configs.os_arch)[0][:-1].split("-")[-1]})' - f'{color["ENDC"]}') + f'{color["endc"]}') else: - print(f'[{color["CYAN"]} install {color["ENDC"]}] -> ' + print(f'[{color["cyan"]} install {color["endc"]}] -> ' f'{sbo}-{version}') def _view_installed_packages(self, name: str): - ''' View and creates list with packages for remove. ''' + """ View and creates list with packages for remove. """ installed = os.listdir(self.configs.log_packages) color = self.colors() @@ -143,9 +148,10 @@ class ViewMessage: self.configs.sbo_repo_tag in package and black not in self.black.get()): self.installed_packages.append(package) - print(f'[{color["RED"]} delete {color["ENDC"]}] -> {package}') + print(f'[{color["red"]} delete {color["endc"]}] -> {package}') def _view_total(self, slackbuilds: list, dependencies: list, option: str): + """ View the status of the packages action. """ color = self.colors() slackbuilds.extend(dependencies) @@ -158,25 +164,25 @@ class ViewMessage: installed += 1 if option == 'install': - print(f'\n{color["GREY"]}Total {installed} packages will be ' - f'installed and {upgraded} will be upgraded.{color["ENDC"]}') + print(f'\n{color["grey"]}Total {installed} packages will be ' + f'installed and {upgraded} will be upgraded.{color["endc"]}') elif option == 'build': - print(f'\n{color["GREY"]}Total {installed + upgraded} packages ' - f'will be build.{color["ENDC"]}') + print(f'\n{color["grey"]}Total {installed + upgraded} packages ' + f'will be build.{color["endc"]}') elif option == 'remove': - print(f'\n{color["GREY"]}Total {installed + upgraded} packages ' - f'will be removed.{color["ENDC"]}') + print(f'\n{color["grey"]}Total {installed + upgraded} packages ' + f'will be removed.{color["endc"]}') def logs_packages(self, dependencies): print('The following logs will be removed:\n') color = self.colors() for dep in dependencies: - print(f'{color["CYAN"]}{dep[0]}{color["ENDC"]}') + print(f'{color["cyan"]}{dep[0]}{color["endc"]}') print(' |') - print(f' +->{color["CYAN"]} {dep[1]}{color["ENDC"]}\n') + print(f' +->{color["cyan"]} {dep[1]}{color["endc"]}\n') print('Note: After cleaning you should remove them one by one.') def question(self): From a3daaa1ab85021b040f01c688a4c8cfaefcd10bb Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 17:47:10 +0200 Subject: [PATCH 02/17] Fixed code style Signed-off-by: Dimitris Zlatanidis --- slpkg/main.py | 21 +++++++++------------ slpkg/views/view_package.py | 1 + slpkg/views/views.py | 4 ++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 743d9f96..560dfbcc 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -25,6 +25,15 @@ class Argparse: def __init__(self, args): self.args: list = args + self.usage = Usage() + + if len(self.args) == 0: + self.usage.help_short() + + self.flags = [] + self.check = Check() + self.configs = Configs + self.check.blacklist(self.args) self.options = ['--yes', '--jobs', @@ -32,18 +41,6 @@ class Argparse: '--reinstall', '--skip-installed'] - if len(self.args) == 0: - self.usage.help_short() - - self.flags = [] - self.configs = Configs - self.usage = Usage() - self.flag() - self.check = Check() - - self.check.blacklist(self.args) - - def flag(self): for option in self.options: if option in self.args: self.args.remove(option) diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 6c0ad5eb..b9b1f2bb 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -19,6 +19,7 @@ class ViewPackage: self.colors = self.configs.colour def package(self, packages): + """ View the packages from the repository. """ http = urllib3.PoolManager() color = self.colors() green = color['green'] diff --git a/slpkg/views/views.py b/slpkg/views/views.py index d72402bd..aa32d70b 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -24,6 +24,7 @@ class ViewMessage: self.installed_packages = [] def build_packages(self, slackbuilds: list, dependencies: list): + """ View packages for build only. """ print('The following packages will be build:\n') for sbo in slackbuilds: @@ -39,6 +40,7 @@ class ViewMessage: self._view_total(slackbuilds, dependencies, option='build') def install_packages(self, slackbuilds: list, dependencies: list): + """ View packages for install. """ print('The following packages will be installed or upgraded:\n') for sbo in slackbuilds: @@ -176,6 +178,7 @@ class ViewMessage: f'will be removed.{color["endc"]}') def logs_packages(self, dependencies): + """ View the logging packages. """ print('The following logs will be removed:\n') color = self.colors() @@ -186,6 +189,7 @@ class ViewMessage: print('Note: After cleaning you should remove them one by one.') def question(self): + """ Manage the proceed. """ if '--yes' not in self.flags: answer = input('\nDo you want to continue [y/N]: ') print() From 9355f58ba8b0fcecf1ced9396f9d14edf64485ba Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 18:58:16 +0200 Subject: [PATCH 03/17] Fixed flags Signed-off-by: Dimitris Zlatanidis --- slpkg/checksum.py | 2 +- slpkg/clean_logs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 38c99be5..5bd043b1 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -25,7 +25,7 @@ class Md5sum: print('Found:', file_check) print(f'\nMD5SUM check for {name} FAILED.') - view = ViewMessage() + view = ViewMessage(self.flags) view.question() @staticmethod diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py index 47a44c63..c5cb2c29 100644 --- a/slpkg/clean_logs.py +++ b/slpkg/clean_logs.py @@ -19,7 +19,7 @@ class CleanLogsDependencies: LogsDependencies.name, LogsDependencies.requires).all() if dependencies: - view = ViewMessage() + view = ViewMessage(self.flags) view.logs_packages(dependencies) view.question() From 7fd273478750a8d1781be8829dce45ec3d990017 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 19:01:46 +0200 Subject: [PATCH 04/17] Updated for version 4.3.5 --- ChangeLog.txt | 6 ++++++ README.rst | 4 ++-- setup.cfg | 2 +- slpkg/views/version.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 630bf2d5..e90191ca 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +4.3.5 - 07/12/2022 +Updated: +- Code style +Fixed: +- Flags parameter + 4.3.4 - 02/12/2022 Updated: - Remove dataclasses and switch to __init__ diff --git a/README.rst b/README.rst index f40c629b..cb3ad18b 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Date: Wed, 7 Dec 2022 19:12:34 +0200 Subject: [PATCH 05/17] Fixed bash function script Signed-off-by: Dimitris Zlatanidis --- install.sh | 2 +- slackbuild/slpkg.SlackBuild | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 270c1156..85ca0079 100755 --- a/install.sh +++ b/install.sh @@ -24,7 +24,7 @@ __version() { # Grab version from __metadata_.py file -cat setup.cfg | grep "version =" | tr -d [[:space:]] | cut -c9-13 | tr , . +cat setup.cfg | grep "version =" | tr -d "[:space:]" | cut -c9-13 | tr , . } PRGNAM=slpkg diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index d5ce5569..b0d43695 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -24,7 +24,7 @@ __version() { # Grab version from __metadata_.py file -cat ../setup.cfg | grep "version =" | tr -d [[:space:]] | cut -c9-13 | tr , . +cat ../setup.cfg | grep "version =" | tr -d "[:space:]" | cut -c9-13 | tr , . } cd $(dirname $0) ; CWD=$(pwd) From fef62843683ac2ad79a5914af1bac5fd2459c255 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 19:18:24 +0200 Subject: [PATCH 06/17] Fixed typo --- slpkg/utilities.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 88932102..7171e17e 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -31,14 +31,14 @@ class Utilities: @staticmethod def remove_file_if_exists(path: str, file: str): - """ Clean the the old files. """ + """ Clean the old files. """ archive = f'{path}/{file}' if os.path.isfile(archive): os.remove(archive) @staticmethod def remove_folder_if_exists(path: str, folder: str): - """ Clean the the old folders. """ + """ Clean the old folders. """ directory = f'{path}/{folder}' if os.path.isdir(directory): shutil.rmtree(directory) From 7b52fd467b79355c69b0ffa64d7547ea53ba2f51 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 19:24:30 +0200 Subject: [PATCH 07/17] Fixed typo --- slpkg/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 7a09df6a..e1be310d 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -8,7 +8,7 @@ from slpkg.configs import Configs class Wget: - """ Wget donwloader. """ + """ Wget downloader. """ def __init__(self): self.wget_options: str = Configs.wget_options From e78af756ee45a67af1997563f3144b65a7b1b9bc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 19:25:06 +0200 Subject: [PATCH 08/17] Fixed code style --- slpkg/create_data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/slpkg/create_data.py b/slpkg/create_data.py index deace01d..2f151554 100644 --- a/slpkg/create_data.py +++ b/slpkg/create_data.py @@ -28,8 +28,7 @@ class CreateData: 'SLACKBUILD SHORT DESCRIPTION:' ] - sbo_file = self.read_file( - f'{self.configs.sbo_repo_path}/SLACKBUILDS.TXT') + sbo_file = self.read_file(f'{self.configs.sbo_repo_path}/SLACKBUILDS.TXT') cache = [] # init cache From 4f7e586197f4857444cc58bf34d0230c20f5a0f8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 7 Dec 2022 19:25:43 +0200 Subject: [PATCH 09/17] Fixed code style --- slpkg/configs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/configs.py b/slpkg/configs.py index 94cd6a89..02447590 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -51,7 +51,7 @@ class Configs: # Wget options wget_options = '-c -N' - ''' Overwrite with user configuration. ''' + # Overwrite with user configuration. config_file: str = f'{etc_path}/{prog_name}.toml' if os.path.isfile(config_file): with open(config_file, 'rb') as conf: From 5a0de1e9570461e7b80224b0e5b3fc48a102c107 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:20:14 +0200 Subject: [PATCH 10/17] Rename built-in function --- slpkg/update_repository.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index 92df2133..28d7f147 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -37,8 +37,8 @@ class UpdateRepository: data.insert_sbo_table() @staticmethod - def delete_file(dir: str, txt_file: str): - file = f'{dir}/{txt_file}' + def delete_file(folder: str, txt_file: str): + file = f'{folder}/{txt_file}' if path.exists(file): os.remove(file) From 4e57f90109fc2d1dff4287715931686b6d113090 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:22:29 +0200 Subject: [PATCH 11/17] Fixed: Expected type dict',got '() -> Any' instead --- slpkg/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/search.py b/slpkg/search.py index 9fdc498b..74093cf0 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -10,7 +10,7 @@ class SearchPackage: """ Search slackbuilds from the repository. """ def __init__(self): - self.colors: dict = Configs.colour + self.colors = Configs.colour def package(self, packages): color = self.colors() From cde973f7e5a09c50f263cd37c320fe8ea0f2aeac Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:23:29 +0200 Subject: [PATCH 12/17] Fixed docstring --- slpkg/queries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/queries.py b/slpkg/queries.py index 98c72459..101ee59e 100644 --- a/slpkg/queries.py +++ b/slpkg/queries.py @@ -9,7 +9,7 @@ from slpkg.models.models import session as Session class SBoQueries: - ''' Queries class for the sbo repository. ''' + """ Queries class for the sbo repository. """ def __init__(self, name): self.name = name From 65baa631a8596c2e8b48cc5c53f79e484e57746c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:25:21 +0200 Subject: [PATCH 13/17] Fixed typo --- slpkg/configs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/configs.py b/slpkg/configs.py index 02447590..ec1dae8e 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -93,7 +93,7 @@ class Configs: except KeyError: pass - # Creating the paths if they doesn't exists + # Creating the paths if not exists paths = [tmp_slpkg, build_path, download_only, From 95e834606affe10f98a91695647eaff46a8df6f5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:26:32 +0200 Subject: [PATCH 14/17] Fixed typo --- slpkg/views/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index aa32d70b..68357819 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -189,7 +189,7 @@ class ViewMessage: print('Note: After cleaning you should remove them one by one.') def question(self): - """ Manage the proceed. """ + """ Manage to proceed. """ if '--yes' not in self.flags: answer = input('\nDo you want to continue [y/N]: ') print() From c1d1af904e27dcf2e298b6e9deff00c7a7297bd7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:27:13 +0200 Subject: [PATCH 15/17] Fixed typo --- slpkg/views/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/version.py b/slpkg/views/version.py index bc20e7ad..c18d5eac 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -3,7 +3,7 @@ class Version: - """ Print the vesrsion. """ + """ Print the version. """ def __init__(self): self.version_info: tuple = (4, 3, 5) From b6c6cdd519442e1689c9c07ad37e5664cb4a005a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:44:46 +0200 Subject: [PATCH 16/17] Updated readme --- README.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.rst b/README.rst index cb3ad18b..58461e33 100644 --- a/README.rst +++ b/README.rst @@ -74,6 +74,40 @@ Usage If you need more information try to use slpkg manpage. + $ slpkg install Flask + The following packages will be installed or upgraded: + + [ install ] -> Flask-2.1.2 + + Dependencies: + [ install ] -> python-zipp-3.8.0 + [ install ] -> python-importlib_metadata-4.10.1 + [ install ] -> click-8.1.3 + [ install ] -> python3-itsdangerous-2.1.2 + [ install ] -> werkzeug-2.1.2 + + Total 6 packages will be installed and 0 will be upgraded. + + Do you want to continue [y/N]: + + + $ slpkg remove Flask + The following packages will be removed: + + [ delete ] -> Flask-2.1.2-x86_64-1_SBo + + Dependencies: + [ delete ] -> python-zipp-3.8.0-x86_64-2_SBo + [ delete ] -> python-importlib_metadata-4.10.1-x86_64-1_SBo + [ delete ] -> click-8.1.3-x86_64-1_SBo + [ delete ] -> python3-itsdangerous-2.1.2-x86_64-1_SBo + [ delete ] -> werkzeug-2.1.2-x86_64-1_SBo + + Total 6 packages will be removed. + + Do you want to continue [y/N]: + + Configuration files ------------------- From 71b6862d48895d0b4c296f10dbf367f9789a12b7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Dec 2022 19:47:04 +0200 Subject: [PATCH 17/17] Updated readme --- README.rst | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 58461e33..6119cf93 100644 --- a/README.rst +++ b/README.rst @@ -75,37 +75,37 @@ Usage $ slpkg install Flask - The following packages will be installed or upgraded: + The following packages will be installed or upgraded: - [ install ] -> Flask-2.1.2 + [ install ] -> Flask-2.1.2 - Dependencies: - [ install ] -> python-zipp-3.8.0 - [ install ] -> python-importlib_metadata-4.10.1 - [ install ] -> click-8.1.3 - [ install ] -> python3-itsdangerous-2.1.2 - [ install ] -> werkzeug-2.1.2 + Dependencies: + [ install ] -> python-zipp-3.8.0 + [ install ] -> python-importlib_metadata-4.10.1 + [ install ] -> click-8.1.3 + [ install ] -> python3-itsdangerous-2.1.2 + [ install ] -> werkzeug-2.1.2 - Total 6 packages will be installed and 0 will be upgraded. + Total 6 packages will be installed and 0 will be upgraded. - Do you want to continue [y/N]: + Do you want to continue [y/N]: - $ slpkg remove Flask - The following packages will be removed: + $ slpkg remove Flask + The following packages will be removed: - [ delete ] -> Flask-2.1.2-x86_64-1_SBo + [ delete ] -> Flask-2.1.2-x86_64-1_SBo - Dependencies: - [ delete ] -> python-zipp-3.8.0-x86_64-2_SBo - [ delete ] -> python-importlib_metadata-4.10.1-x86_64-1_SBo - [ delete ] -> click-8.1.3-x86_64-1_SBo - [ delete ] -> python3-itsdangerous-2.1.2-x86_64-1_SBo - [ delete ] -> werkzeug-2.1.2-x86_64-1_SBo + Dependencies: + [ delete ] -> python-zipp-3.8.0-x86_64-2_SBo + [ delete ] -> python-importlib_metadata-4.10.1-x86_64-1_SBo + [ delete ] -> click-8.1.3-x86_64-1_SBo + [ delete ] -> python3-itsdangerous-2.1.2-x86_64-1_SBo + [ delete ] -> werkzeug-2.1.2-x86_64-1_SBo - Total 6 packages will be removed. + Total 6 packages will be removed. - Do you want to continue [y/N]: + Do you want to continue [y/N]: Configuration files