def add_to_target(self, task, target, *link, check=True): linkname = slugify(list(link)) if link else None try: if check and linkname in self.targets[target]: error('Link "{}" already in target "{}"'.format(linkname, target)) except TypeError: error('Target must be a string, not {}'.format(type(target).__name__)) self.targets[target][linkname] = task task.targets.append((target, linkname)) return task
def add_dependency(self, task, *links, needed=False, escape=True): if not links: link = None else: link, links = links[0], links[1:] if self == task: error('Task cannot depend on itself: {}'.format(self)) self.children.append(task) if link is not None: linkname = slugify(link) if escape else link else: self.noname_link_counter += 1 linkname = '_{}'.format(self.noname_link_counter) self.links[linkname] = Task.Link(task, links, needed) task.parents.append((self, linkname)) return self