def add(self, task=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 task is None or task in (Task, 'task'): t = Task() t.conf = self.conf self.queue.append(t) return t elif task in (MapTask, 'map'): t = MapTask() t.conf = self.conf self.queue.append(t) return t elif task in (BuildApp, 'app'): self.create_pool() t = BuildApp(self.conf) t.pool = self.pool t.root_app = False self.queue.append(t) return t else: if isinstance(task, Task): if task.conf is None: task.conf = self.conf self.queue.append(task) return task elif isinstance(task, BuildApp): self.create_pool() task.root_app = False task.pool = self.pool self.queue.append(task) return task else: raise TypeError('invalid task type')