Exemplo n.º 1
0
    def run_task(self, task, *args, **kwargs):
        if hasattr(self, task):
            fun = getattr(self, task)

            if has_mark(fun, 'task'):
                fun(*args, **kwargs)
                return True

        return False
Exemplo n.º 2
0
    def run_task(self, task, *args, **kwargs):
        if hasattr(self, task):
            fun = getattr(self, task)

            if has_mark(fun, 'task'):
                fun(*args, **kwargs)
                return True

        return False
Exemplo n.º 3
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'))
Exemplo n.º 4
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
Exemplo n.º 5
0
    def __decorate(func):
        if not has_mark(func, 'matchers'):
            set_mark(func, 'matchers', [])

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