Example #1
0
def triad_superset(triads):
    """
    From a list of triads, remove all triads that are more restrictive than other triads.
    """
    final = []
    while triads:
        # Pick first triad from the list and make it reference
        query = triads.pop()
        # Include the reference only if it cannot be matched by another triad
        # Namely, discard the triad if it can be matched by another triad
        if not match_any(query, triads):
            final.append(query)
    return final
 def test_no_match_any(self):
     self.assertFalse(match_any("a::b::c", ["a::b::d"]))
     self.assertFalse(match_any("a::b::c", ["a::c::*"]))
     self.assertFalse(match_any("a::b::c", ["a::*::b"]))
     self.assertFalse(match_any("a::b::c", ["*::a::c"]))
Example #3
0
 def test(queries, reference, strict=True):
     return reduce(
         lambda t, p: t or match_any(p, reference, strict=strict),
         queries, False)
 def test_match_any(self):
     self.assertTrue(match_any("a::b::c", ["a::b::c"]))
     self.assertTrue(match_any("a::b::c", ["a::b::*"]))
     self.assertTrue(match_any("a::b::c", ["a::*::c"]))
     self.assertTrue(match_any("a::b::c", ["*::b::c"]))