From: Zac Medico Date: Sun, 13 May 2012 09:05:14 +0000 (-0700) Subject: Use _pkg_str.version more. X-Git-Tag: v2.2.0_alpha105~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1564b9b0f549256fe0b8e552ae7bedd10754d61e;p=portage.git Use _pkg_str.version more. --- diff --git a/pym/portage/versions.py b/pym/portage/versions.py index f9fb606d7..85928a847 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -393,6 +393,10 @@ def cpv_getkey(mycpv, eapi=None): def cpv_getversion(mycpv, eapi=None): """Returns the v (including revision) from an cpv.""" + try: + return mycpv.version + except AttributeError: + pass cp = cpv_getkey(mycpv, eapi=eapi) if cp is None: return None @@ -446,10 +450,16 @@ def best(mymatches, eapi=None): if len(mymatches) == 1: return mymatches[0] bestmatch = mymatches[0] - p2 = catpkgsplit(bestmatch, eapi=eapi)[1:] + try: + v2 = bestmatch.version + except AttributeError: + v2 = _pkg_str(bestmatch, eapi=eapi).version for x in mymatches[1:]: - p1 = catpkgsplit(x, eapi=eapi)[1:] - if pkgcmp(p1, p2) > 0: + try: + v1 = x.version + except AttributeError: + v1 = _pkg_str(x, eapi=eapi).version + if vercmp(v1, v2) > 0: bestmatch = x - p2 = catpkgsplit(bestmatch, eapi=eapi)[1:] + v2 = v1 return bestmatch