Esempio n. 1
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {'b1': BoolFilterSpec(lambda i: i['v'], needed_keys=('a', 'b')),
                        'b2': BoolFilterSpec(lambda i: len(i['v']) > 3, needed_keys=('c', 'b')),
                        'everything': BoolFilterSpec(None, aliases=('all',))}
     COMPARATIVE_FILTERS = {'c': CmpFilterSpec(value_type=str, value_getter=lambda i: i['v'],
                                               needed_keys=('c', 'a')),
                            'ci': CmpFilterSpec(value_type=str, value_getter=lambda i: i['v'].casefold(),
                                                needed_keys=('b', 'd'))}
     DEFAULT_FILTER = 'c'
Esempio n. 2
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {
         'b1': BoolFilterSpec(lambda i: bool(x),
                              aliases=('b1a', 'b1A')),
         'b2': BoolFilterSpec(lambda i: bool(x), aliases=('b2a', 'b2A'))
     }
     COMPARATIVE_FILTERS = {
         'c1':
         CmpFilterSpec(value_type=str,
                       value_getter=NotImplemented,
                       aliases=('c1a', 'c1A')),
         'c2':
         CmpFilterSpec(value_type=str,
                       value_getter=NotImplemented,
                       aliases=('c2a', 'c2A'))
     }
     DEFAULT_FILTER = 'c1'
Esempio n. 3
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {
         'b': BoolFilterSpec(lambda i: bool(x), aliases=('foo', ))
     }
     COMPARATIVE_FILTERS = {
         'c':
         CmpFilterSpec(value_type=str,
                       value_getter=NotImplemented,
                       aliases=('bar', 'foo'))
     }
Esempio n. 4
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {'all': BoolFilterSpec(None)}
     COMPARATIVE_FILTERS = {
         'dec':
         CmpFilterSpec(value_type=str, value_getter=lambda x: x['dec']),
         'oct':
         CmpFilterSpec(value_type=str, value_getter=lambda x: x['oct']),
         'hex':
         CmpFilterSpec(value_type=str, value_getter=lambda x: x['hex'])
     }
Esempio n. 5
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {'positive': BoolFilterSpec(lambda i: i['v'] >= 0),
                        'mod2': BoolFilterSpec(lambda i: i['v'] % 2 == 0),
                        'mod3': BoolFilterSpec(lambda i: i['v'] % 3 == 0),
                        'mod4': BoolFilterSpec(lambda i: i['v'] % 4 == 0),
                        'mod5': BoolFilterSpec(lambda i: i['v'] % 5 == 0),
                        'mod10': BoolFilterSpec(lambda i: i['v'] % 10 == 0),
                        'all': BoolFilterSpec(None, aliases=('*',))}
     COMPARATIVE_FILTERS = {'n': CmpFilterSpec(value_type=float, value_getter=lambda i: i['v']),
                            'n_int': CmpFilterSpec(value_type=int, value_getter=lambda i: int(i['v'])),
                            'n_abs': CmpFilterSpec(value_type=int, value_getter=lambda i: abs(i['v']))}
     DEFAULT_FILTER = 'c'
Esempio n. 6
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {'everything': BoolFilterSpec(None)}
     COMPARATIVE_FILTERS = {
         'v': CmpFilterSpec(value_type=str,
                            value_getter=lambda i: i['v'])
     }
Esempio n. 7
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {
         'everything': BoolFilterSpec(None, aliases=('all', ))
     }
Esempio n. 8
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {'all': BoolFilterSpec(None)}
Esempio n. 9
0
 class FooFilter(Filter):
     BOOLEAN_FILTERS = {
         'b1': BoolFilterSpec(lambda i: i['v']),
         'b2': BoolFilterSpec(lambda i: i['v'] >= 0)
     }