예제 #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
예제 #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
예제 #3
0
파일: filter.py 프로젝트: bazsi/codega
        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'))
예제 #4
0
파일: filter.py 프로젝트: bazsi/codega
    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
예제 #5
0
파일: object.py 프로젝트: bazsi/codega
    def __decorate(func):
        if not has_mark(func, 'matchers'):
            set_mark(func, 'matchers', [])

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