diff options
author | Brian Dolbec <brian.dolbec@gmail.com> | 2011-01-09 17:09:08 -0800 |
---|---|---|
committer | Brian Dolbec <brian.dolbec@gmail.com> | 2011-01-09 17:09:08 -0800 |
commit | 000ce49860b253ad6c917c5a58bc0ff31225134a (patch) | |
tree | e65b00fc8c8fdbb7e6803c787ec84651f11da6b1 | |
parent | remove the use of uniqify as it does not work correctly with atoms. (diff) | |
download | gentoolkit-000ce49860b253ad6c917c5a58bc0ff31225134a.tar.gz gentoolkit-000ce49860b253ad6c917c5a58bc0ff31225134a.tar.bz2 gentoolkit-000ce49860b253ad6c917c5a58bc0ff31225134a.zip |
create a new uniqify_atoms() to properly handle a list of atom instances.
set the reverse dependency lookup to use it.
-rw-r--r-- | pym/gentoolkit/atom.py | 7 | ||||
-rw-r--r-- | pym/gentoolkit/dependencies.py | 5 | ||||
-rw-r--r-- | pym/gentoolkit/helpers.py | 14 |
3 files changed, 22 insertions, 4 deletions
diff --git a/pym/gentoolkit/atom.py b/pym/gentoolkit/atom.py index eb4a358..fe9adaa 100644 --- a/pym/gentoolkit/atom.py +++ b/pym/gentoolkit/atom.py @@ -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: diff --git a/pym/gentoolkit/dependencies.py b/pym/gentoolkit/dependencies.py index 6dc6a76..6aadc35 100644 --- a/pym/gentoolkit/dependencies.py +++ b/pym/gentoolkit/dependencies.py @@ -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 diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py index ab0cdbd..cf1b138 100644 --- a/pym/gentoolkit/helpers.py +++ b/pym/gentoolkit/helpers.py @@ -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: |