Пример #1
0
    def add(self, task=None, conf=None):
        """
        Adds a new :class:`~giza.app.BuildApp()` or :class:`~giza.task.Task()`
        to the :class:`~giza.app.BuildApp()` object.

        :param string,Task,BuildApp task: Optional. If not specified,
           :meth:`~giza.app.BuildApp.add()` creates and returns a new
           :class:`~giza.task.Task()` object. You can pass the string ``task``
           or the class :class:`~giza.task.Task` to explicitly create a new
           Task, or pass an existing :class:`~giza.task.Task()` instance to add
           that task to the :class:`~giza.app.BuildApp()` instance. You can
           also pass the string ``app`` or the :class:`~giza.app.BuildApp`
           class, to create and add new :class:`~giza.app.BuildApp()`: pass an
           existing :class:`~giza.app.BuildApp()` instance to add that that
           operation grouping to the queue.

        :returns: A reference to a :class:`~giza.app.BuildApp()` or
           :class:`~giza.task.Task()` object in the :class:`~giza.app.BuildApp()`

        :raises: :exc:`TypeError` if the ``task`` argument is invalid.

        """
        if conf is not None:
            self.conf = conf

        if task is None or task in (Task, 'task'):
            t = Task()
            t.conf = self.conf
            t.force = self.force
            self.queue.append(t)
            return t
        elif task in (MapTask, 'map'):
            t = MapTask()
            t.conf = self.conf
            t.force = self.force
            self.queue.append(t)
            return t
        elif task in (BuildApp, 'app'):
            t = self.sub_app()
            self.queue.append(t)
            return t
        else:
            if isinstance(task, Task):
                task.force = self.force
                if task.conf is None:
                    task.conf = self.conf

                self.queue.append(task)
                return task
            elif isinstance(task, BuildApp):
                task.root_app = False
                task.defualt_pool = self.default_pool
                task.force = self.force
                task.pool = self.pool
                self.queue.append(task)
                return task
            else:
                raise TypeError('invalid task type')
Пример #2
0
    def add(self, task=None, conf=None):
        """
        Adds a new :class:`~giza.app.BuildApp()` or :class:`~giza.task.Task()`
        to the :class:`~giza.app.BuildApp()` object.

        :param string,Task,BuildApp task: Optional. If not specified,
           :meth:`~giza.app.BuildApp.add()` creates and returns a new
           :class:`~giza.task.Task()` object. You can pass the string ``task``
           or the class :class:`~giza.task.Task` to explicitly create a new
           Task, or pass an existing :class:`~giza.task.Task()` instance to add
           that task to the :class:`~giza.app.BuildApp()` instance. You can
           also pass the string ``app`` or the :class:`~giza.app.BuildApp`
           class, to create and add new :class:`~giza.app.BuildApp()`: pass an
           existing :class:`~giza.app.BuildApp()` instance to add that that
           operation grouping to the queue.

        :returns: A reference to a :class:`~giza.app.BuildApp()` or
           :class:`~giza.task.Task()` object in the :class:`~giza.app.BuildApp()`

        :raises: :exc:`TypeError` if the ``task`` argument is invalid.

        """
        if conf is not None:
            self.conf = conf

        if task is None or task in (Task, 'task'):
            t = Task()
            t.conf = self.conf
            t.force = self.force
            self.queue.append(t)
            return t
        elif task in (MapTask, 'map'):
            t = MapTask()
            t.conf = self.conf
            t.force = self.force
            self.queue.append(t)
            return t
        elif task in (BuildApp, 'app'):
            t = self.sub_app()
            self.queue.append(t)
            return t
        else:
            if isinstance(task, Task):
                task.force = self.force
                if task.conf is None:
                    task.conf = self.conf

                self.queue.append(task)
                return task
            elif isinstance(task, BuildApp):
                task.root_app = False
                task.defualt_pool = self.default_pool
                task.force = self.force
                task.pool = self.pool
                self.queue.append(task)
                return task
            else:
                raise TypeError('invalid task type')