From: Zac Medico Date: Sun, 4 Oct 2009 21:55:41 +0000 (-0000) Subject: Make pkgsplit() accept a cpv again, since accepting a pv only will probably X-Git-Tag: v2.2_rc44~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9bf57bb9c6c41f4dacd9253d688174084384d601;p=portage.git Make pkgsplit() accept a cpv again, since accepting a pv only will probably break lots of api consumers. Thanks to Romain Perier for reporting epkginfo breakage. svn path=/main/trunk/; revision=14491 --- diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 54ed863ed..60e58b894 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -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)