Changeset ferringb%2Fpkgcore-dev,3519

Show
Ignore:
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:
2 modified

Legend:

Unmodified
Added
Removed
  • ferringb/pkgcore-dev/NEWS

    r3518 r3519  
    44See ChangeLog for full commit logs; this is summarized/major changes. 
    55 
     6 
     7* ticket 201; pquery --restrict-revdep-pkgs wasn't behaving properly for  
     8  slot/repository/user atoms, now does. 
    69 
    710* Correct potential segfaults in cpython version of PackageRestriction and 
  • ferringb/pkgcore-dev/pkgcore/scripts/pquery.py

    r3467 r3519  
    1313    commandline, repo_utils, parserestrict, packages as pkgutils) 
    1414from snakeoil.demandload import demandload 
    15 demandload(globals(), 're') 
     15from snakeoil.compatibility import any 
     16demandload(globals(), 're', 'snakeoil.currying:partial') 
    1617 
    1718 
     
    278279        raise optparse.OptionValueError('option %s: %s' % (opt_str, e)) 
    279280 
     281def revdep_pkgs_match(pkgs, value): 
     282    return any(value.match(pkg) for pkg in pkgs) 
    280283 
    281284class OptionParser(commandline.OptionParser): 
     
    443446            help='print what condition(s) trigger a dep.') 
    444447 
    445     def check_values(self, values, args): 
     448    def check_values(self, vals, args): 
    446449        """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) 
    448451        # Interpret args with parens in them as --expr additions, the 
    449452        # rest as --match additions (since parens are invalid in --match). 
     
    541544            l = [] 
    542545            # odd?  a bit; we allow strs to reuse parse_revdep 
    543             for atom in revdep_pkgs: 
     546            for atom_inst in revdep_pkgs: 
    544547                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) 
    553559 
    554560        # Build up a restriction.