Use the Atom class to implement dep_getkey(), and fall back to legacy code
authorZac Medico <zmedico@gentoo.org>
Mon, 14 Sep 2009 06:02:36 +0000 (06:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 14 Sep 2009 06:02:36 +0000 (06:02 -0000)
when necessary for backward compatibility.

svn path=/main/trunk/; revision=14254

pym/portage/dep.py

index 847c76eae83e4d8a6eace1101fb27169ab8141b7..8dbcdd65718f03edbca569adaf395d54523c6e6f 100644 (file)
@@ -995,6 +995,16 @@ def dep_getkey(mydep):
        cp = getattr(mydep, "cp", None)
        if cp is not None:
                return cp
+
+       try:
+               return Atom(mydep).cp
+       except InvalidAtom:
+               try:
+                       return Atom('=' + mydep).cp
+               except InvalidAtom:
+                       pass
+
+       # Fall back to legacy code for backward compatibility.
        mydep = dep_getcpv(mydep)
        if mydep and isspecific(mydep):
                mysplit = catpkgsplit(mydep)