diff options
author | Dan McGee <dan@archlinux.org> | 2012-07-31 20:27:43 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-08-04 15:11:27 -0500 |
commit | a64bbbd4139d91cbbca10d804067cbd87a95872d (patch) | |
tree | 51f46c613f4eec820c9dacd432e7329e9721f3f9 /main/models.py | |
parent | 566a9803dd4928fa2145ef14da2d59d2631eeb05 (diff) |
Make adjustments for optional -> deptype conversion
Very little dealt directly with this field.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r-- | main/models.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py index 577f11c6..f4ced350 100644 --- a/main/models.py +++ b/main/models.py @@ -245,13 +245,18 @@ class Package(models.Model): deps = [] arches = None # TODO: we can use list comprehension and an 'in' query to make this more effective - for dep in self.depends.order_by('optional', 'name'): + for dep in self.depends.all(): pkg = dep.get_best_satisfier() providers = None if not pkg: providers = dep.get_providers() deps.append({'dep': dep, 'pkg': pkg, 'providers': providers}) - return deps + # sort the list; deptype sorting makes this tricker than expected + sort_order = {'D': 0, 'O': 1, 'M': 2, 'C': 3} + def sort_key(val): + dep = val['dep'] + return (sort_order.get(dep.deptype, 1000), dep.name) + return sorted(deps, key=sort_key) @cache_function(125) def base_package(self): |