Changeset ferringb%2Fpkgcore-dev,3519
- Timestamp:
- 07/15/08 11:29:07 (5 weeks ago)
- Author:
- Brian Harring <ferringb@…>
- Message:
-
mangle check_values a bit to avoid name conflicts; additionally, fix ticket 201 in the process so that it does actual match attempts against the pkg instances that match
- Location:
- ferringb/pkgcore-dev
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3518
|
r3519
|
|
| 4 | 4 | See ChangeLog for full commit logs; this is summarized/major changes. |
| 5 | 5 | |
| | 6 | |
| | 7 | * ticket 201; pquery --restrict-revdep-pkgs wasn't behaving properly for |
| | 8 | slot/repository/user atoms, now does. |
| 6 | 9 | |
| 7 | 10 | * Correct potential segfaults in cpython version of PackageRestriction and |
-
|
r3467
|
r3519
|
|
| 13 | 13 | commandline, repo_utils, parserestrict, packages as pkgutils) |
| 14 | 14 | from snakeoil.demandload import demandload |
| 15 | | demandload(globals(), 're') |
| | 15 | from snakeoil.compatibility import any |
| | 16 | demandload(globals(), 're', 'snakeoil.currying:partial') |
| 16 | 17 | |
| 17 | 18 | |
| … |
… |
|
| 278 | 279 | raise optparse.OptionValueError('option %s: %s' % (opt_str, e)) |
| 279 | 280 | |
| | 281 | def revdep_pkgs_match(pkgs, value): |
| | 282 | return any(value.match(pkg) for pkg in pkgs) |
| 280 | 283 | |
| 281 | 284 | class OptionParser(commandline.OptionParser): |
| … |
… |
|
| 443 | 446 | help='print what condition(s) trigger a dep.') |
| 444 | 447 | |
| 445 | | def check_values(self, values, args): |
| | 448 | def check_values(self, vals, args): |
| 446 | 449 | """Sanity check and postprocess after parsing.""" |
| 447 | | vals, args = commandline.OptionParser.check_values(self, values, args) |
| | 450 | vals, args = commandline.OptionParser.check_values(self, vals, args) |
| 448 | 451 | # Interpret args with parens in them as --expr additions, the |
| 449 | 452 | # rest as --match additions (since parens are invalid in --match). |
| … |
… |
|
| 541 | 544 | l = [] |
| 542 | 545 | # odd? a bit; we allow strs to reuse parse_revdep |
| 543 | | for atom in revdep_pkgs: |
| | 546 | for atom_inst in revdep_pkgs: |
| 544 | 547 | for repo in vals.repos: |
| 545 | | l.extend(parse_revdep(str(x.versioned_atom)) |
| 546 | | for x in repo.itermatch(atom)) |
| 547 | | vals.restrict_revdep_pkgs = l |
| 548 | | if len(l) == 1: |
| 549 | | vals.restrict.append(l[0]) |
| 550 | | else: |
| 551 | | vals.restrict.append(packages.OrRestriction(finalize=True, |
| 552 | | *l)) |
| | 548 | l.extend(repo.itermatch(atom_inst)) |
| | 549 | # have our pkgs; now build the restrict. |
| | 550 | r = values.FlatteningRestriction(atom.atom, |
| | 551 | values.AnyMatch(values.FunctionRestriction( |
| | 552 | partial(revdep_pkgs_match, tuple(l)) |
| | 553 | ))) |
| | 554 | vals.restrict_revdep_pkgs = packages.OrRestriction(finalize=True, |
| | 555 | *list( |
| | 556 | packages.PackageRestriction(dep, r) |
| | 557 | for dep in ('depends', 'rdepends', 'post_rdepends'))) |
| | 558 | vals.restrict.append(vals.restrict_revdep_pkgs) |
| 553 | 559 | |
| 554 | 560 | # Build up a restriction. |