diff options
Diffstat (limited to 'pym/portage_versions.py')
-rw-r--r-- | pym/portage_versions.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pym/portage_versions.py b/pym/portage_versions.py index 7c5717987..7492d606e 100644 --- a/pym/portage_versions.py +++ b/pym/portage_versions.py @@ -243,3 +243,17 @@ def catpkgsplit(mydata,silent=1): def catsplit(mydep): return mydep.split("/", 1) +def best(mymatches): + """Accepts None arguments; assumes matches are valid.""" + if mymatches is None: + return "" + if not len(mymatches): + return "" + bestmatch = mymatches[0] + p2 = catpkgsplit(bestmatch)[1:] + for x in mymatches[1:]: + p1 = catpkgsplit(x)[1:] + if pkgcmp(p1, p2) > 0: + bestmatch = x + p2 = catpkgsplit(bestmatch)[1:] + return bestmatch |