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 showPrompt(hasTopic): if hasTopic: prompt = "Enter topic number or search term" else: prompt = "Enter search term" prompt += " (empty input or 'q' to quit): " try: answer = tui.editLine("", prompt) except KeyboardInterrupt: print return None answer = answer.lower() if answer == "q": return "" return answer
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_p_edit(self, line): """Edit a project. p_edit <project name>""" project = dbutils.getOrCreateProject(line, createIfNeeded=False) if not project: raise YokadiException("Project does not exist.") # Create project line projectLine = parseutils.createLine(project.name, "", project.getKeywordDict()) # Edit line = tui.editLine(projectLine) # Update project projectName, garbage, keywordDict = parseutils.parseLine(line) if garbage: raise YokadiException("Cannot parse line, got garbage (%s)" % garbage) if not dbutils.createMissingKeywords(keywordDict.keys()): return project.name = projectName project.setKeywordDict(keywordDict)