From 262bd57c668798dc4b1ca7652a9a4ac216e68878 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 12 Aug 2012 17:58:29 +0100 Subject: [PATCH] Fixed package-implementation scoring If the distribution list contained a match followed by an even better one, we failed to add anything at all. --- zeroinstall/injector/model.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/zeroinstall/injector/model.py b/zeroinstall/injector/model.py index 6471d7d..e8efb5d 100644 --- a/zeroinstall/injector/model.py +++ b/zeroinstall/injector/model.py @@ -1208,15 +1208,14 @@ class ZeroInstallFeed(object): for item, item_attrs in self._package_implementations: distro_names = item_attrs.get('distributions', '') - added_this = False - for distro_name in distro_names.split(' '): - score = distro.get_score(distro_name) if distro_name else 0.5 - if score > best_score: - best_score = score - best_impls = [] - if score == best_score and not added_this: - best_impls.append((item, item_attrs)) - added_this = True + score_this_item = max( + distro.get_score(distro_name) if distro_name else 0.5 + for distro_name in distro_names.split(' ')) + if score_this_item > best_score: + best_score = score_this_item + best_impls = [] + if score_this_item == best_score: + best_impls.append((item, item_attrs)) return best_impls def get_name(self): -- 2.11.4.GIT