Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Make a pattern or function to a test function (returns True or False)
Catch it's exception and consider False instread of throw out

        def maketest(orig):
    """
    Make a pattern or function to a test function (returns True or False)
    Catch it's exception and consider False instread of throw out
    """    
    # for pattern, use it's own test interface
    import pattern
    if isinstance(orig, pattern.Pattern):
        return orig.test

    # for other function, catch exception and turn it to False
    def func(value):
        try:
            return bool(orig(value))
        except BaseException, e:
            return False
        


src/s/o/solo-HEAD/bak/dset.py   solo(Download)
    def __init__(self, func):
        Hook.__init__(self, func)
 
        self.test = func
        self.filter_func = util.maketest(func)

src/s/o/solo-HEAD/bak/tpl.py   solo(Download)
    def __init__(self, *cases):
        self.cases = []
        for idx in range(0, len(cases), 2):
            self.cases.append((util.maketest(Template(cases[idx])), Template(cases[idx + 1])))