create a new uniqify_atoms() to properly handle a list of atom instances.
authorBrian Dolbec <brian.dolbec@gmail.com>
Mon, 10 Jan 2011 01:09:08 +0000 (17:09 -0800)
committerBrian Dolbec <brian.dolbec@gmail.com>
Mon, 10 Jan 2011 01:09:08 +0000 (17:09 -0800)
set the reverse dependency lookup to use it.

pym/gentoolkit/atom.py
pym/gentoolkit/dependencies.py
pym/gentoolkit/helpers.py

index eb4a358b5d7468e010cc2799d6a1326ae6e326fe..fe9adaa4bc858eccca3e746fb8580ef61c5f8cd2 100644 (file)
@@ -344,4 +344,11 @@ class Atom(portage.dep.Atom, CPV):
                raise NotImplementedError(
                        'Someone added an operator without adding it to intersects')
 
+       def get_depstr(self):
+               """Returns a string representation of the original dep
+               """
+               uc = self.use_conditional
+               uc = "%s? " % uc if uc is not None else ''
+               return "%s%s" % (uc, self.atom)
+
 # vim: set ts=4 sw=4 tw=79:
index 6dc6a7650b81e74857d9ed32397d3ebdc09cb482..6aadc35da64fcb01803d12f531b90532f46139c4 100644 (file)
@@ -19,7 +19,7 @@ from portage.dep import paren_reduce
 from gentoolkit import errors
 from gentoolkit.atom import Atom
 from gentoolkit.cpv import CPV
-from gentoolkit.helpers import uniqify
+from gentoolkit.helpers import uniqify_atoms
 from gentoolkit.dbapi import PORTDB, VARDB
 from gentoolkit.query import Query
 
@@ -243,8 +243,7 @@ class Dependencies(Query):
                        try:
                                all_depends = depcache[pkgdep]
                        except KeyError:
-                               #all_depends = uniqify(pkgdep.get_all_depends())
-                               all_depends = pkgdep.get_all_depends()
+                               all_depends = uniqify_atoms(pkgdep.get_all_depends())
                                depcache[pkgdep] = all_depends
 
                        dep_is_displayed = False
index ab0cdbd4891f416acb1abc5bfb367a3f26b9b28f..cf1b138066201aba5480204ce436e741a2e567a7 100644 (file)
@@ -449,7 +449,7 @@ def get_bintree_cpvs(predicate=None):
        for cpv in chain.from_iterable(BINDB.cp_list(x) for x in installed_cps):
                yield cpv
 
-       
+
 def print_file(path):
        """Display the contents of a file."""
 
@@ -476,4 +476,16 @@ def uniqify(seq, preserve_order=True):
 
        return result
 
+def uniqify_atoms(seq):
+       """Return a uniqified list."""
+       seen = set()
+       result = []
+       for x in seq:
+               dep = x.get_depstr()
+               if dep not in seen:
+                       result.append(x)
+                       seen.add(dep)
+
+       return result
+
 # vim: set ts=4 sw=4 tw=79: