Make pkgsplit() accept a cpv again, since accepting a pv only will probably
authorZac Medico <zmedico@gentoo.org>
Sun, 4 Oct 2009 21:55:41 +0000 (21:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 4 Oct 2009 21:55:41 +0000 (21:55 -0000)
break lots of api consumers. Thanks to Romain Perier <mrpouet@g.o> for
reporting epkginfo breakage.

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

pym/portage/versions.py

index 54ed863ed352ebe39f31d9b5520f6af89ad89ea7..60e58b894f2cca65c49705009844eff05e3e6c8d 100644 (file)
@@ -228,7 +228,7 @@ def pkgcmp(pkg1, pkg2):
 
 _pv_re = re.compile('^' + _pv + '$', re.VERBOSE)
 
-def pkgsplit(mypkg,silent=1):
+def _pkgsplit(mypkg):
 
        m = _pv_re.match(mypkg)
        if m is None:
@@ -269,10 +269,10 @@ def catpkgsplit(mydata,silent=1):
        p_split=None
        if len(mysplit)==1:
                cat = "null"
-               p_split=pkgsplit(mydata,silent=silent)
+               p_split = _pkgsplit(mydata)
        elif len(mysplit)==2:
                cat = mysplit[0]
-               p_split=pkgsplit(mysplit[1],silent=silent)
+               p_split = _pkgsplit(mysplit[1])
        if not p_split:
                catcache[mydata]=None
                return None
@@ -280,6 +280,23 @@ def catpkgsplit(mydata,silent=1):
        catcache[mydata]=retval
        return retval
 
+def pkgsplit(mypkg, silent=1):
+       """
+       @param mypkg: either a pv or cpv
+       @return:
+       1. None if input is invalid.
+       2. (pn, ver, rev) if input is pv
+       3. (cp, ver, rev) if input is a cpv
+       """
+       catpsplit = catpkgsplit(mypkg)
+       if catpsplit is None:
+               return None
+       cat, pn, ver, rev = catpsplit
+       if cat == 'null':
+               return (pn, ver, rev)
+       else:
+               return (cat + '/' + pn, ver, rev)
+
 def catsplit(mydep):
         return mydep.split("/", 1)