Move portage.best() to portage_versions.
authorZac Medico <zmedico@gentoo.org>
Sat, 22 Jul 2006 11:19:17 +0000 (11:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 22 Jul 2006 11:19:17 +0000 (11:19 -0000)
svn path=/main/trunk/; revision=3990

pym/portage.py
pym/portage_versions.py

index fd9c9d5a2df05d514393a61d065ee8eb35353eed..ab52fda4258679cac80a29418f160ae1af576d8d 100644 (file)
@@ -95,7 +95,8 @@ try:
                parse_updates, update_config_files, update_dbentries
 
        # Need these functions directly in portage namespace to not break every external tool in existence
-       from portage_versions import ververify,vercmp,catsplit,catpkgsplit,pkgsplit,pkgcmp
+       from portage_versions import best, catpkgsplit, catsplit, pkgcmp, \
+               pkgsplit, vercmp, ververify
 
        # endversion and endversion_keys are for backward compatibility only.
        from portage_versions import endversion_keys
@@ -3632,22 +3633,6 @@ class packagetree:
                populated=1
                pass
 
-def best(mymatches):
-       "accepts None arguments; assumes matches are valid."
-       global bestcount
-       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
-
 def match_to_list(mypkg,mylist):
        """(pkgname,list)
        Searches list for entries that matches the package.
index 7c5717987b0718743d3cc99baad9c537147f1bdc..7492d606e3ed0e5b578ee1ac104896aa796aad99 100644 (file)
@@ -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