Make dep_getcpv() use Atom, and fall back to legacy code for backward compat.
authorZac Medico <zmedico@gentoo.org>
Mon, 14 Sep 2009 08:11:22 +0000 (08:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 14 Sep 2009 08:11:22 +0000 (08:11 -0000)
svn path=/main/trunk/; revision=14262

pym/portage/dep.py

index 782405f49e7b85db919707d6fada008fa17c11bf..ae6d43ab5ad4b09079b8426a5c76096bb8cb3c9d 100644 (file)
@@ -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):