diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-02-20 09:28:03 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-02-20 09:28:03 +0000 |
commit | d749345233c833c5aecac1489276885a8845eeb5 (patch) | |
tree | 8f9b9e5bc73e7bd4168797dee9bb6408f6f2423c /pym/portage/versions.py | |
parent | 557ff227cf80f0d2dc88ca668c28cd2c6f60d85c (diff) | |
download | portage-d749345233c833c5aecac1489276885a8845eeb5.tar.gz portage-d749345233c833c5aecac1489276885a8845eeb5.tar.bz2 portage-d749345233c833c5aecac1489276885a8845eeb5.zip |
Move portage.cpv_getkey() to the portage.versions module.
svn path=/main/trunk/; revision=15410
Diffstat (limited to 'pym/portage/versions.py')
-rw-r--r-- | pym/portage/versions.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 5ab3aaeb5..c8159741b 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -3,7 +3,14 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +__all__ = [ + 'best', 'catpkgsplit', 'catsplit', + 'cpv_getkey', 'pkgcmp', 'pkgsplit', + 'ververify', 'vercmp' +] + import re +import warnings # \w is [a-zA-Z0-9_] @@ -309,6 +316,26 @@ def pkgsplit(mypkg, silent=1): else: return (cat + '/' + pn, ver, rev) +def cpv_getkey(mycpv): + """Calls catpkgsplit on a cpv and returns only the cp.""" + mysplit = catpkgsplit(mycpv) + if mysplit is not None: + return mysplit[0] + '/' + mysplit[1] + + warnings.warn("portage.versions.cpv_getkey() " + \ + "called with invalid cpv: '%s'" % (mycpv,), + DeprecationWarning, stacklevel=2) + + myslash = mycpv.split("/", 1) + mysplit = _pkgsplit(myslash[-1]) + if mysplit is None: + return None + mylen = len(myslash) + if mylen == 2: + return myslash[0] + "/" + mysplit[0] + else: + return mysplit[0] + def catsplit(mydep): return mydep.split("/", 1) |