[aur] initial retrievement of update requirements implementation

This commit is contained in:
Vinícius Moreira
2020-02-07 19:09:11 -03:00
parent bb0b986d87
commit 58a5be9f67
5 changed files with 79 additions and 4 deletions

View File

@@ -446,3 +446,28 @@ class GenericSoftwareManager(SoftwareManager):
sorted_list.extend(pkgs)
return sorted_list
def get_update_requirements(self, pkgs: List[SoftwarePackage], watcher: ProcessWatcher) -> List[SoftwarePackage]:
by_manager = {}
for pkg in pkgs:
man = self._get_manager_for(pkg)
if man:
man_pkgs = by_manager.get(man)
if man_pkgs is None:
man_pkgs = []
by_manager[man] = man_pkgs
man_pkgs.append(pkg)
required = []
if by_manager:
for man, pkgs in by_manager.items():
ti = time.time()
required.extend(man.get_update_requirements(pkgs, watcher))
tf = time.time()
self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(tf - ti))
return required

View File

@@ -107,11 +107,14 @@ class UpdateSelectedApps(AsyncAction):
app_config = config.read_config()
models = [view.model for view in self.pkgs]
required_pkgs = self.manager.get_update_requirements(models, self)
if bool(app_config['updates']['sort_packages']):
self.change_substatus(self.i18n['action.update.status.sorting'])
sorted_pkgs = self.manager.sort_update_order([view.model for view in self.pkgs])
sorted_pkgs = self.manager.sort_update_order()
else:
sorted_pkgs = [view.model for view in self.pkgs]
sorted_pkgs = models
for pkg in sorted_pkgs:
self.change_substatus('')