def do_bug_edit(self, line): """Edit a bug. bug_edit <id>""" task = dbutils.getTaskFromId(line) # Create task line taskLine = parseutils.createLine("", task.title, task.getKeywordDict()) # Edit while True: print "(Press Ctrl+C to cancel)" try: line = tui.editLine(taskLine) if not line.strip(): tui.warning("Indicate a bug title !") continue except KeyboardInterrupt: print print "Cancelled" return foo, title, keywordDict = parseutils.parseLine(task.project.name+" "+line) if dbutils.updateTask(task, task.project.name, title, keywordDict): break editBugKeywords(keywordDict) task.setKeywordDict(keywordDict) # Update bug task.urgency = computeUrgency(keywordDict)
def do_t_edit(self, line): """Edit a task. t_edit <id>""" def editComplete(text, state): """ Specific completer for the edit prompt. This subfunction should stay here because it needs to access to cmd members""" if state == 0: origline = readline.get_line_buffer() line = origline.lstrip() stripped = len(origline) - len(line) begidx = readline.get_begidx() - stripped endidx = readline.get_endidx() - stripped if begidx>0: self.completion_matches = projectAndKeywordCompleter("", text, line, begidx, endidx, shift=1) else: self.completion_matches = [] try: return self.completion_matches[state] except IndexError: return None old_completer = readline.get_completer() # Backup previous completer to restore it in the end readline.set_completer(editComplete) # Switch to specific completer task = dbutils.getTaskFromId(line) # Create task line taskLine = parseutils.createLine("", task.title, task.getKeywordDict()) while True: # Edit print "(Press Ctrl+C to cancel)" try: line = tui.editLine(taskLine) if not line.strip(): tui.warning("Indicate a task title !") continue except KeyboardInterrupt: print print "Cancelled" readline.set_completer(old_completer) # Restore standard completer return foo, title, keywordDict = parseutils.parseLine(task.project.name+" "+line) if dbutils.updateTask(task, task.project.name, title, keywordDict): break readline.set_completer(old_completer) # Restore standard completer
def do_t_urgency(self, line): """Defines urgency of a task. t_urgency <id> <value>""" tokens = line.split(" ") if len(tokens)!=2: raise YokadiException("You must provide a taskId and an urgency value") task = dbutils.getTaskFromId(tokens[0]) try: # Do not use isdigit(), so that we can set negative urgency. This # make it possible to stick tasks to the bottom of the list. urgency = int(tokens[1]) except ValueError: raise YokadiException("Task urgency must be a digit") if urgency>100: tui.warning("Max urgency is 100") urgency=100 elif urgency<-99: tui.warning("Min urgency is -99") urgency=-99 task.urgency = urgency