From bb160436634cf872fa25c592871e2f6da589ecf5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 14 Sep 2009 08:11:22 +0000 Subject: [PATCH] Make dep_getcpv() use Atom, and fall back to legacy code for backward compat. svn path=/main/trunk/; revision=14262 --- pym/portage/dep.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 782405f49..ae6d43ab5 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -738,8 +738,6 @@ def get_operator(mydep): return operator -_dep_getcpv_cache = {} - def dep_getcpv(mydep): """ Return the category-package-version with any operators/slot specifications stripped off @@ -753,13 +751,13 @@ def dep_getcpv(mydep): @rtype: String @return: The depstring with the operator removed """ - cpv = getattr(mydep, "cpv", None) - if cpv is not None: - return cpv - global _dep_getcpv_cache - retval = _dep_getcpv_cache.get(mydep, None) - if retval is not None: - return retval + + try: + return Atom(mydep).cpv + except InvalidAtom: + pass + + # Fall back to legacy code for backward compatibility. mydep_orig = mydep if mydep: mydep = remove_slot(mydep) @@ -776,7 +774,6 @@ def dep_getcpv(mydep): mydep = mydep[2:] elif mydep[:1] in "=<>~": mydep = mydep[1:] - _dep_getcpv_cache[mydep_orig] = mydep return mydep def dep_getslot(mydep): -- 2.26.2