Exemple #1
0
    def __decorator(func):
        if not has_mark(func, 'filters'):
            set_mark(func, 'filters', [])

        # Since the add_filter will mostly be used as a decorator and because decorators
        # are applied in reverse order (the closest one to the function definition gets
        # applied first) we should apply the new filter to the beginning of the list so
        # the filter statements are easier to read.
        get_mark(func, 'filters').insert(0, filter)

        return func
Exemple #2
0
        def __decorator(func):
            if not has_mark(func, 'filters'):
                raise FilterError('The current function was marked as a %s yet it has no filters defined' % cls.__name__)

            generator = func
            if subfactory is not None:
                generator = subfactory(generator)

            # Collect the filter definitions, if there are any.
            return cls(generator, *get_mark(func, 'filters'))
Exemple #3
0
    def __decorate(func):
        if not has_mark(func, 'matchers'):
            set_mark(func, 'matchers', [])

        get_mark(func, 'matchers').append(matcher)
        return func