diff --git a/ChangeLog.txt b/ChangeLog.txt index 33e3feb3..00195883 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +4.4.6 - 06/01/2023 +Updated: +- Improve speed for dependees +Fixed: +- summary for build +Remove: +- python-toml dependency + 4.4.5 - 03/01/2023 Added: - New modern view mode style diff --git a/README.rst b/README.rst index fa33a62c..3fdf3fee 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,6 @@ Requirements SQLAlchemy >= 1.4.36 pythondialog >= 3.5.3 progress >= 1.6 - toml >= 0.10.2 Install ------- @@ -32,8 +31,8 @@ Install from the official third-party `SBo repository = 1.4.46 pythondialog >= 3.5.3 -progress >= 1.6 -toml >= 0.10.2 \ No newline at end of file +progress >= 1.6 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index aaac060a..22817a84 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = 4.4.5 +version = 4.4.6 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com @@ -41,7 +41,6 @@ install_requires = SQLAlchemy >= 1.4.36 pythondialog >= 3.5.3 progress >= 1.6 - toml >= 0.10.2 include_package_data = True [options.packages.find] diff --git a/slpkg/dependees.py b/slpkg/dependees.py index ca70e3d9..0a7d3b6f 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -1,11 +1,10 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -from progress.spinner import PixelSpinner - from slpkg.configs import Configs from slpkg.views.ascii import Ascii -from slpkg.queries import SBoQueries +from slpkg.models.models import SBoTable +from slpkg.models.models import session as Session class Dependees: @@ -15,19 +14,19 @@ class Dependees: self.packages = packages self.flags = flags self.configs = Configs + self.session = Session self.ascii = Ascii() self.llc = self.ascii.lower_left_corner self.hl = self.ascii.horizontal_line self.var = self.ascii.vertical_and_right self.colors = self.configs.colour - self.colors = self.configs.colour self.color = self.colors() self.bold = self.color['bold'] self.violet = self.color['violet'] self.cyan = self.color['cyan'] self.grey = self.color['grey'] self.yellow = self.color['yellow'] - self.bviolet = f'{self.bold}{self.violet}' + self.byellow = f'{self.bold}{self.yellow}' self.endc = self.color['endc'] def slackbuilds(self): @@ -35,40 +34,30 @@ class Dependees: print(f"The list below shows the " f"packages that dependees on '{', '.join([p for p in self.packages])}':\n") - dependees = {} - spinner = PixelSpinner(f'{self.endc}Collecting the data... {self.bviolet}') - for package in self.packages: - found = [] # Reset list every package - sbos = SBoQueries('').sbos() + for pkg in self.packages: + dependees = list(self.find_requires(pkg)) + print(f'{self.byellow}{pkg}{self.endc}') + print(f' {self.llc}{self.hl}', end='') + if not dependees: + print(f'{self.cyan}No dependees{self.endc}') - for sbo in sbos: - requires = SBoQueries(sbo).requires() - spinner.next() + sp = ' ' * 4 + for i, dep in enumerate(dependees, start=1): + if i == 1: + print(f' {self.cyan}{dep[0]}{self.endc}') + else: + print(f'{sp}{self.cyan}{dep[0]}{self.endc}') - if package in requires: - found.append(sbo) - dependees[package] = found - - last = f' {self.llc}{self.hl}' - print('\n') - if dependees: - for key, value in dependees.items(): - print(f'{self.yellow}{key}{self.endc}') - print(end=f'\r{last}') - char = f' {self.var}{self.hl}' - - for i, v in enumerate(value, start=1): - if i == len(value): - char = last - - if i == 1: - print(f'{self.cyan}{v}{self.endc}') + if '--full-reverse' in self.flags: + if i == len(dependees): + print(" " * 4 + f' {self.llc}{self.hl} {self.violet}{dep[1]}{self.endc}') else: - print(f'{" " * 3}{self.cyan}{v}{self.endc}') + print(" " * 4 + f' {self.var}{self.hl} {self.violet}{dep[1]}{self.endc}') + print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n') - if '--full-reverse' in self.flags: - print(f'{" " * 4}{char} {" ".join([req for req in SBoQueries(v).requires()])}') - - print(f'\n{self.grey}{len(value)} dependees for {key}{self.endc}\n') - else: - print(f'{self.endc}No dependees found.\n') + def find_requires(self, sbo): + """ Find requires that slackbuild dependees. """ + requires = self.session.query(SBoTable.name, SBoTable.requires).all() + for req in requires: + if [r for r in req[1].split() if r == sbo]: + yield req diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 6cf1e614..b6778ffc 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -20,8 +20,10 @@ class Downloader: self.configs = Configs self.colors = self.configs.colour self.color = self.colors() + self.bold = self.color['bold'] self.green = self.color['green'] self.yellow = self.color['yellow'] + self.byellow = f'{self.bold}{self.yellow}' self.endc = self.color['endc'] self.progress = ProgressBar() self.stderr = None @@ -52,7 +54,7 @@ class Downloader: # Terminate process 2 if process 1 finished if not p1.is_alive(): - print(f'{self.endc}{self.yellow} Done{self.endc}', end='') + print(f'{self.endc}{self.byellow} Done{self.endc}', end='') p2.terminate() # Wait until process 2 finish diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index c9b669b9..5f921916 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -23,7 +23,9 @@ class RemovePackages: self.configs = Configs self.colors = self.configs.colour self.color = self.colors() + self.bold = self.color['bold'] self.yellow = self.color['yellow'] + self.byellow = f'{self.bold}{self.yellow}' self.red = self.color['red'] self.endc = self.color['endc'] self.installed_packages = [] @@ -93,7 +95,7 @@ class RemovePackages: # Terminate process 2 if process 1 finished if not p1.is_alive(): - print(f'{self.endc}{self.yellow} Done{self.endc}', end='') + print(f'{self.endc}{self.byellow} Done{self.endc}', end='') p2.terminate() # Wait until process 2 finish diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index e1c7637e..d92180ac 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -37,9 +37,11 @@ class Slackbuilds: self.configs = Configs self.colors = self.configs.colour self.color = self.colors() + self.bold = self.color['bold'] self.cyan = self.color['cyan'] self.red = self.color['red'] self.yellow = self.color['yellow'] + self.byellow = f'{self.bold}{self.yellow}' self.endc = self.color['endc'] self.install_order = [] self.dependencies = [] @@ -299,7 +301,7 @@ class Slackbuilds: # Terminate process 2 if process 1 finished if not p1.is_alive(): - print(f'{self.endc}{self.yellow} Done{self.endc}', end='') + print(f'{self.endc}{self.byellow} Done{self.endc}', end='') p2.terminate() # Wait until process 2 finish diff --git a/slpkg/views/version.py b/slpkg/views/version.py index 080a4083..42f8a536 100644 --- a/slpkg/views/version.py +++ b/slpkg/views/version.py @@ -5,7 +5,7 @@ class Version: """ Print the version. """ def __init__(self): - self.version_info = (4, 4, 5) + self.version_info = (4, 4, 6) self.version = '{0}.{1}.{2}'.format(*self.version_info) self.license = 'MIT License' self.author = 'Dimitris Zlatanidis (dslackw)' diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index a33910fb..2ce2cce0 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -4,8 +4,8 @@ import urllib3 from slpkg.configs import Configs -from slpkg.models.models import SBoTable from slpkg.queries import SBoQueries +from slpkg.models.models import SBoTable from slpkg.models.models import session as Session diff --git a/slpkg/views/views.py b/slpkg/views/views.py index f61bf2d3..dc10da5e 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -231,8 +231,6 @@ class ViewMessage: upgrade += 1 elif installed and option == 'remove': remove += 1 - else: - build += 1 self.draw_bottom_line() @@ -241,7 +239,7 @@ class ViewMessage: f'installed and {upgrade} will be upgraded.{self.endc}') elif option == 'build': - print(f'{self.grey}Total {build} packages ' + print(f'{self.grey}Total {len(slackbuilds)} packages ' f'will be build in {self.configs.tmp_path} folder.{self.endc}') elif option == 'remove':