diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-07-23 12:13:04 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-07-23 09:47:13 -0700 |
commit | a8803ef754e3875e1876472a18102c4110f65914 (patch) | |
tree | a94e6b1d35b960d6878c56b6a9d4b131c3231b39 /pym/portage/dep/__init__.py | |
parent | 5aad2271e99bce1c30b4dce107f3d8041d6b339f (diff) | |
download | portage-a8803ef754e3875e1876472a18102c4110f65914.tar.gz portage-a8803ef754e3875e1876472a18102c4110f65914.tar.bz2 portage-a8803ef754e3875e1876472a18102c4110f65914.zip |
portage.dep.{match_from_list,best_match_to_list}: Add support for wildcards in atoms
Diffstat (limited to 'pym/portage/dep/__init__.py')
-rw-r--r-- | pym/portage/dep/__init__.py | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index fdb38f7c4..bd5cfcc86 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -936,7 +936,7 @@ _atom_re = re.compile('^(?P<without_use>(?:' + '(?P<op>' + _op + _cpv + ')|' + '(?P<star>=' + _cpv + r'\*)|' + '(?P<simple>' + _cp + '))(:' + _slot + ')?)(' + _use + ')?$', re.VERBOSE) -_atom_wildcard_re = re.compile('(?P<simple>((' + _cat + '|\*)/(' + _pkg + '|\*)))') +_atom_wildcard_re = re.compile('(?P<simple>((' + _cat + '|\*)/(' + _pkg + '|\*)))$') def isvalidatom(atom, allow_blockers=False): """ @@ -1094,10 +1094,13 @@ def best_match_to_list(mypkg, mylist): - >=cpv 2 - <=cpv 2 - cp 1 + - */p 0 + - c/* 0 + - */* -1 """ operator_values = {'=':6, '~':5, '=*':4, '>':2, '<':2, '>=':2, '<=':2, None:1} - maxvalue = 0 + maxvalue = -2 bestm = None for x in match_to_list(mypkg, mylist): if dep_getslot(x) is not None: @@ -1105,6 +1108,16 @@ def best_match_to_list(mypkg, mylist): maxvalue = 3 bestm = x op_val = operator_values[x.operator] + if x.operator is None: + c, p = catsplit(x) + if c == "*": + if p == "*": + op_val = -1 + else: + op_val = 0 + elif p == "*": + op_val = 0 + if op_val > maxvalue: maxvalue = op_val bestm = x @@ -1129,7 +1142,7 @@ def match_from_list(mydep, candidate_list): if "!" == mydep[:1]: mydep = mydep[1:] if not isinstance(mydep, Atom): - mydep = Atom(mydep) + mydep = Atom(mydep, allow_wildcard=True) mycpv = mydep.cpv mycpv_cps = catpkgsplit(mycpv) # Can be None if not specific @@ -1161,10 +1174,18 @@ def match_from_list(mydep, candidate_list): if cp is None: mysplit = catpkgsplit(remove_slot(x)) if mysplit is not None: - cp = mysplit[0] + '/' + mysplit[1] - if cp != mycpv: - continue - mylist.append(x) + c = mysplit[0] + p = mysplit[1] + else: + continue + else: + mysplit = catsplit(cp) + c = mysplit[0] + p = mysplit[1] + + if cat in (c, "*") and pkg in (p, "*"): + mylist.append(x) + elif operator == "=": # Exact match for x in candidate_list: |