From d4080244029245c07332a71e6452dd6d7cb02fd6 Mon Sep 17 00:00:00 2001 From: Lucas Severo Date: Tue, 28 Jun 2016 16:42:27 -0300 Subject: [PATCH] consider packages without popcon (dev) Signed-off-by: Lucas Severo Signed-off-by: Lucas Mattioli --- pet/classifier.py | 67 +++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/pet/classifier.py b/pet/classifier.py index c9619f7..02ebdea 100644 --- a/pet/classifier.py +++ b/pet/classifier.py @@ -175,35 +175,52 @@ def __init__(self, session, named_trees, nt, bugs.get(nt.source, []), suite_packages.get(nt.source, []), tags.get(nt.package_id, []))) + def order_packages_by_popcon(self, packages): + has_no_popcon = [] + packages_queue = PriorityQueue() + for package in packages: + package_popcon = popcon.package(package.name) + + # The package has popcon + if package_popcon: + packages_queue.put((-package_popcon[package.name], package)) + else: + has_no_popcon.append(package) + + ordered_packages = [] + while packages_queue.empty() is False: + _, package = packages_queue.get() + ordered_packages.append(package) + + for package in has_no_popcon: + ordered_packages.append(package) + + return ordered_packages + def classify(self): + self.packages = self.order_packages_by_popcon(self.packages) classified = dict() - ordered_packages = PriorityQueue() - for p in self.packages: - if p.ready_for_upload: - cls = 'ready_for_upload' - elif p.has_rc_bugs: - cls = 'rc_bugs' - elif p.missing_tag: - cls = 'missing_tag' - elif not p.tags: - cls = 'new' - elif p.newer_upstream: - cls = 'new_upstream' - elif p.watch_problem: - cls = 'watch_problem' - elif p.bugs: - cls = 'bugs' - elif not p.is_tagged: - cls = 'wip' + for package in self.packages: + if package.ready_for_upload: + classification = 'ready_for_upload' + elif package.has_rc_bugs: + classification = 'rc_bugs' + elif package.missing_tag: + classification = 'missing_tag' + elif not package.tags: + classification = 'new' + elif package.newer_upstream: + classification = 'new_upstream' + elif package.watch_problem: + classification = 'watch_problem' + elif package.bugs: + classification = 'bugs' + elif not package.is_tagged: + classification = 'wip' else: - cls = 'other' + classification = 'other' - package_popcon = popcon.package(p.name) - if package_popcon: - ordered_packages.put((-package_popcon[p.name], cls, p)) - while ordered_packages.empty() is False: - _, cls, package = ordered_packages.get() - classified.setdefault(cls, []).append(package) + classified.setdefault(classification, []).append(package) return classified