diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-05-13 01:36:25 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-05-13 01:36:25 -0700 |
commit | f31320b67c9f593a2a8592e1a4e547f5f641943a (patch) | |
tree | b5fbe65ded8a1ffc75ccf5f80c50e0872ad6972a /pym/portage/dep | |
parent | depgraph: minimize match_from_list operations (diff) | |
download | portage-f31320b67c9f593a2a8592e1a4e547f5f641943a.tar.gz portage-f31320b67c9f593a2a8592e1a4e547f5f641943a.tar.bz2 portage-f31320b67c9f593a2a8592e1a4e547f5f641943a.zip |
_pkg_str: add version attribute for comparisons
This attribute can be passed directly into vercmp, avoiding the need to
generate this string many times.
Diffstat (limited to 'pym/portage/dep')
-rw-r--r-- | pym/portage/dep/__init__.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index d4888e086..240e2237f 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -1141,9 +1141,11 @@ class Atom(_atom_base): self.__dict__['cp'] = cp try: self.__dict__['cpv'] = _pkg_str(cpv) + self.__dict__['version'] = self.cpv.version except InvalidData: # plain cp, wildcard, or something self.__dict__['cpv'] = cpv + self.__dict__['version'] = None self.__dict__['repo'] = repo self.__dict__['slot'] = slot self.__dict__['operator'] = op @@ -2003,15 +2005,17 @@ def match_from_list(mydep, candidate_list): mylist.append(x) elif operator in [">", ">=", "<", "<="]: - mysplit = ["%s/%s" % (cat, pkg), ver, rev] for x in candidate_list: - xs = getattr(x, "cpv_split", None) - if xs is None: - xs = catpkgsplit(remove_slot(x)) - xcat, xpkg, xver, xrev = xs - xs = ["%s/%s" % (xcat, xpkg), xver, xrev] + if not hasattr(x, 'cp'): + try: + x = _pkg_str(remove_slot(x)) + except InvalidData: + continue + + if x.cp != mydep.cp: + continue try: - result = pkgcmp(xs, mysplit) + result = vercmp(x.version, mydep.version) except ValueError: # pkgcmp may return ValueError during int() conversion writemsg(_("\nInvalid package name: %s\n") % x, noiselevel=-1) raise |