Improve speed

This commit is contained in:
Dimitris Zlatanidis 2023-01-06 22:10:35 +02:00
parent 79f8570a6b
commit 048a694c16
2 changed files with 31 additions and 38 deletions

View file

@ -1,3 +1,7 @@
4.4.6 - 06/01/2023
Updated:
- Improve speed for dependees
4.4.5 - 03/01/2023
Added:
- New modern view mode style

View file

@ -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 found{self.endc}')
for sbo in sbos:
requires = SBoQueries(sbo).requires()
spinner.next()
sp = ' ' * 3
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