def test_basic(self): for negate in (False, True): inst = values.FlatteningRestriction( tuple, values.AnyMatch(values.EqualityMatch(None)), negate=negate) self.assertEqual(not negate, inst.match([7, 8, [9, None]])) self.assertEqual(negate, inst.match([7, 8, (9, None)])) # Just check this does not raise self.assertTrue(str(inst)) self.assertTrue(repr(inst))
def parse_revdep(value): """Value should be an atom, packages with deps intersecting that match.""" try: targetatom = atom.atom(value) except atom.MalformedAtom as e: raise argparser.error(e) val_restrict = values.FlatteningRestriction( atom.atom, values.AnyMatch(values.FunctionRestriction(targetatom.intersects))) return packages.OrRestriction(*list( packages.PackageRestriction(dep, val_restrict) for dep in ('bdepend', 'depend', 'rdepend', 'pdepend')))
def revdep_pkgs_finalize(sequence, namespace): if not sequence: return [] l = [] for atom_inst in sequence: for repo in namespace.repos: l.extend(repo.itermatch(atom_inst)) # have our pkgs; now build the restrict. any_restrict = values.AnyMatch( values.FunctionRestriction(partial(_revdep_pkgs_match, tuple(l)))) r = values.FlatteningRestriction(atom.atom, any_restrict) return list( packages.PackageRestriction(dep, r) for dep in ('bdepend', 'depend', 'rdepend', 'pdepend'))