summaryrefslogtreecommitdiffstats
path: root/pym/portage_dep.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-05 11:52:50 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-05 11:52:50 +0000
commit66e33621c11d633b456b287c9512bd1f1166a5d3 (patch)
tree914a0390889dfffe1e710b4e0a22562364fe7885 /pym/portage_dep.py
parent8c38f4f5e3538dd948eba1cdc2647d930d63743b (diff)
downloadportage-66e33621c11d633b456b287c9512bd1f1166a5d3.tar.gz
portage-66e33621c11d633b456b287c9512bd1f1166a5d3.tar.bz2
portage-66e33621c11d633b456b287c9512bd1f1166a5d3.zip
Improve best_match_to_list() and include support for slot deps.
svn path=/main/trunk/; revision=4598
Diffstat (limited to 'pym/portage_dep.py')
-rw-r--r--pym/portage_dep.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/pym/portage_dep.py b/pym/portage_dep.py
index af4a72501..932c3e3c4 100644
--- a/pym/portage_dep.py
+++ b/pym/portage_dep.py
@@ -273,15 +273,31 @@ def match_to_list(mypkg, mylist):
def best_match_to_list(mypkg, mylist):
"""(pkgname, list)
- Returns the most specific entry (assumed to be the longest one)
- that matches the package given.
+ Returns the most specific entry that matches the package given.
+ Type Value
+ =cpv 6
+ ~cpv 5
+ =cpv* 4
+ cp:slot 3
+ >cpv 2
+ <cpv 2
+ >=cpv 2
+ <=cpv 2
+ cp 1
"""
- # XXX Assumption is wrong sometimes.
- maxlen = 0
+ operator_values = {'=':6, '~':5, '=*':4,
+ '>':2, '<':2, '>=':2, '<=':2, None:1}
+ maxvalue = 0
bestm = None
for x in match_to_list(mypkg, mylist):
- if len(x) > maxlen:
- maxlen = len(x)
+ if dep_getslot(x) is not None:
+ if maxvalue < 3:
+ maxvalue = 3
+ bestm = x
+ continue
+ op_val = operator_values[get_operator(x)]
+ if op_val > maxvalue:
+ maxvalue = op_val
bestm = x
return bestm