def removePrerequisites(self): self.__relationsToRestore = dict() for task in self.items: prerequisites, dependencies = task.prerequisites(), task.dependencies() self.__relationsToRestore[task] = prerequisites, dependencies task.removeTaskAsDependencyOf(prerequisites) task.removeTaskAsPrerequisiteOf(dependencies)
def removePrerequisites(self): self.__relationsToRestore = dict() for task in self.items: prerequisites, dependencies = task.prerequisites( ), task.dependencies() self.__relationsToRestore[task] = prerequisites, dependencies task.removeTaskAsDependencyOf(prerequisites) task.removeTaskAsPrerequisiteOf(dependencies)
def __removePrerequisites(self, event): self.__relationsToRestore = dict() # pylint: disable-msg=W0201 for task in self.items: prerequisites, dependencies = task.prerequisites(), task.dependencies() self.__relationsToRestore[task] = prerequisites, dependencies task.removeTaskAsDependencyOf(prerequisites, event=event) task.removeTaskAsPrerequisiteOf(dependencies, event=event) task.setPrerequisites([], event=event) task.setDependencies([], event=event)
def addPrerequisitesAndDependencies(tasks): for task in tasks: dummyPrerequisites = task.prerequisites() prerequisites = set() for dummyPrerequisite in dummyPrerequisites: prerequisites.add(tasksById[dummyPrerequisite.id]) task.setPrerequisites(prerequisites) for prerequisite in prerequisites: prerequisite.addDependencies([task]) addPrerequisitesAndDependencies(task.children())
def taskNode(self, parentNode, task): # pylint: disable=W0621 maxDateTime = self.maxDateTime node = self.baseCompositeNode(parentNode, task, 'task', self.taskNode) node.attrib['status'] = str(task.getStatus()) if task.plannedStartDateTime() != maxDateTime: node.attrib['plannedstartdate'] = str(task.plannedStartDateTime()) if task.dueDateTime() != maxDateTime: node.attrib['duedate'] = str(task.dueDateTime()) if task.actualStartDateTime() != maxDateTime: node.attrib['actualstartdate'] = str(task.actualStartDateTime()) if task.completionDateTime() != maxDateTime: node.attrib['completiondate'] = str(task.completionDateTime()) if task.percentageComplete(): node.attrib['percentageComplete'] = str(task.percentageComplete()) if task.recurrence(): self.recurrenceNode(node, task.recurrence()) if task.budget() != date.TimeDelta(): node.attrib['budget'] = self.budgetAsAttribute(task.budget()) if task.priority(): node.attrib['priority'] = str(task.priority()) if task.hourlyFee(): node.attrib['hourlyFee'] = str(task.hourlyFee()) if task.fixedFee(): node.attrib['fixedFee'] = str(task.fixedFee()) reminder = task.reminder() if reminder != maxDateTime and reminder != None: node.attrib['reminder'] = str(reminder) reminderBeforeSnooze = task.reminder(includeSnooze=False) if reminderBeforeSnooze != None and reminderBeforeSnooze < task.reminder(): node.attrib['reminderBeforeSnooze'] = str(reminderBeforeSnooze) prerequisiteIds = ' '.join([prerequisite.id() for prerequisite in \ sortedById(task.prerequisites())]) if prerequisiteIds: node.attrib['prerequisites'] = prerequisiteIds if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.attrib['shouldMarkCompletedWhenAllChildrenCompleted'] = \ str(task.shouldMarkCompletedWhenAllChildrenCompleted()) for effort in sortedById(task.efforts()): self.effortNode(node, effort) for eachNote in sortedById(task.notes()): self.noteNode(node, eachNote) for attachment in sortedById(task.attachments()): self.attachmentNode(node, attachment) return node
def addPrerequisitesAndDependencies(tasks, event): for task in tasks: if task.isDeleted(): # Don't restore prerequisites and dependencies for deleted # tasks task.setPrerequisites([], event=event) continue dummyPrerequisites = task.prerequisites() prerequisites = set() for dummyPrerequisite in dummyPrerequisites: try: prerequisites.add(tasksById[dummyPrerequisite.id]) except KeyError: # Release 1.2.11 and older have a bug where tasks can # have prerequisites listed that don't exist anymore pass task.setPrerequisites(prerequisites, event=event) for prerequisite in prerequisites: prerequisite.addDependencies([task], event=event) addPrerequisitesAndDependencies(task.children(), event)
def taskNode(self, task): # pylint: disable-msg=W0621 maxDateTime = self.maxDateTime node = self.baseCompositeNode(task, 'task', self.taskNode) node.setAttribute('status', str(task.getStatus())) if task.startDateTime() != maxDateTime: node.setAttribute('startdate', str(task.startDateTime())) if task.dueDateTime() != maxDateTime: node.setAttribute('duedate', str(task.dueDateTime())) if task.completionDateTime() != maxDateTime: node.setAttribute('completiondate', str(task.completionDateTime())) if task.percentageComplete() != 0: node.setAttribute('percentageComplete', str(task.percentageComplete())) if task.recurrence(): node.appendChild(self.recurrenceNode(task.recurrence())) if task.budget() != date.TimeDelta(): node.setAttribute('budget', self.budgetAsAttribute(task.budget())) if task.priority() != 0: node.setAttribute('priority', str(task.priority())) if task.hourlyFee() != 0: node.setAttribute('hourlyFee', str(task.hourlyFee())) if task.fixedFee() != 0: node.setAttribute('fixedFee', str(task.fixedFee())) if task.reminder() != None: node.setAttribute('reminder', str(task.reminder())) prerequisiteIds = ' '.join([prerequisite.id() for prerequisite in \ task.prerequisites()]) if prerequisiteIds: node.setAttribute('prerequisites', prerequisiteIds) if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.setAttribute('shouldMarkCompletedWhenAllChildrenCompleted', str(task.shouldMarkCompletedWhenAllChildrenCompleted())) for effort in task.efforts(): node.appendChild(self.effortNode(effort)) for eachNote in task.notes(): node.appendChild(self.noteNode(eachNote)) for attachment in task.attachments(): node.appendChild(self.attachmentNode(attachment)) return node
def taskNode(self, task): # pylint: disable-msg=W0621 node = self.baseCompositeNode(task, "task", self.taskNode) node.setAttribute("status", str(task.getStatus())) if task.startDateTime() != date.DateTime(): node.setAttribute("startdate", str(task.startDateTime())) if task.dueDateTime() != date.DateTime(): node.setAttribute("duedate", str(task.dueDateTime())) if task.completionDateTime() != date.DateTime(): node.setAttribute("completiondate", str(task.completionDateTime())) if task.percentageComplete() != 0: node.setAttribute("percentageComplete", str(task.percentageComplete())) if task.recurrence(): node.appendChild(self.recurrenceNode(task.recurrence())) if task.budget() != date.TimeDelta(): node.setAttribute("budget", self.budgetAsAttribute(task.budget())) if task.priority() != 0: node.setAttribute("priority", str(task.priority())) if task.hourlyFee() != 0: node.setAttribute("hourlyFee", str(task.hourlyFee())) if task.fixedFee() != 0: node.setAttribute("fixedFee", str(task.fixedFee())) if task.reminder() != None: node.setAttribute("reminder", str(task.reminder())) prerequisiteIds = " ".join([prerequisite.id() for prerequisite in task.prerequisites()]) if prerequisiteIds: node.setAttribute("prerequisites", prerequisiteIds) if task.shouldMarkCompletedWhenAllChildrenCompleted() != None: node.setAttribute( "shouldMarkCompletedWhenAllChildrenCompleted", str(task.shouldMarkCompletedWhenAllChildrenCompleted()) ) for effort in task.efforts(): node.appendChild(self.effortNode(effort)) for eachNote in task.notes(): node.appendChild(self.noteNode(eachNote)) for attachment in task.attachments(): node.appendChild(self.attachmentNode(attachment)) return node
def removeDependenciesAndPrerequisites(self, event=None): for task in self.items: for prerequisite in task.prerequisites(): prerequisite.removeDependencies([task], event=event) for dependency in task.dependencies(): dependency.removePrerequisites([task], event=event)