diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-04 21:55:41 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-04 21:55:41 +0000 |
commit | 9bf57bb9c6c41f4dacd9253d688174084384d601 (patch) | |
tree | 6058fe63381d42d65b4ca67fb960ccede4beaf20 | |
parent | b85cfe5ff81688ccca3c4356326447bb057617eb (diff) | |
download | portage-9bf57bb9c6c41f4dacd9253d688174084384d601.tar.gz portage-9bf57bb9c6c41f4dacd9253d688174084384d601.tar.bz2 portage-9bf57bb9c6c41f4dacd9253d688174084384d601.zip |
Make pkgsplit() accept a cpv again, since accepting a pv only will probably
break lots of api consumers. Thanks to Romain Perier <mrpouet@g.o> for
reporting epkginfo breakage.
svn path=/main/trunk/; revision=14491
-rw-r--r-- | pym/portage/versions.py | 23 |
1 files changed, 20 insertions, 3 deletions
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) |