示例#1
0
文件: bugcmd.py 项目: ryanakca/yokadi
    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)
示例#2
0
 def testCreateLine(self):
     for dummy, parsedStruct in gTaskLineToParsedStructList:
         # We do not check the result of createLine() against the
         # original task line because there are many ways to write the same
         # taskLine.
         taskLine = parseutils.createLine(*parsedStruct)
         result = parseutils.parseLine(taskLine)
         self.assertEqual(result, parsedStruct)
示例#3
0
 def do_t_add(self, line):
     """Add new task. Will prompt to create keywords if they do not exist.
     t_add <projectName> [@<keyword1>] [@<keyword2>] <Task description>"""
     if not line:
         print "Give at least a task name !"
         return
     projectName, title, keywordDict = parseutils.parseLine(line)
     if not title:
         raise YokadiException("You should give a task title")
     task = dbutils.addTask(projectName, title, keywordDict)
     if task:
         print "Added task '%s' (id=%d)" % (title, task.id)
     else:
         tui.reinjectInRawInput(u"t_add " + line)
示例#4
0
    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
示例#5
0
 def do_p_add(self, line):
     """Add new project. Will prompt to create keywords if they do not exist.
     p_add <projectName> [@<keyword1>] [@<keyword2>]"""
     if not line:
         print "Give at least a project name !"
         return
     projectName, garbage, keywordDict = parseutils.parseLine(line)
     if garbage:
         raise YokadiException("Cannot parse line, got garbage (%s)" % garbage)
     try:
         project = Project(name=projectName)
     except DuplicateEntryError:
         raise YokadiException("A project named %s already exists. Please find another name" % projectName)
     print "Added project '%s'" % projectName
     if not dbutils.createMissingKeywords(keywordDict.keys()):
         return None
     project.setKeywordDict(keywordDict)
示例#6
0
文件: bugcmd.py 项目: ryanakca/yokadi
    def do_bug_add(self, line):
        """Add a bug-type task. Will create a task and ask additional info.
        bug_add <project_name> [@<keyword1>] [@<keyword2>] <Bug description>
        """
        projectName, title, keywordDict = parseutils.parseLine(line)

        task = dbutils.addTask(projectName, title, keywordDict)
        if not task:
            tui.reinjectInRawInput(u"bug_add " + line)
            return

        editBugKeywords(keywordDict)
        task.setKeywordDict(keywordDict)

        task.urgency = computeUrgency(keywordDict)

        print "Added bug '%s' (id=%d, urgency=%d)" % (title, task.id, task.urgency)
示例#7
0
 def _t_add(self, cmd, line):
     """Code shared by t_add and bug_add."""
     line = line.strip()
     if not line:
         tui.error("Missing parameters")
         self.do_help(cmd)
         return None
     projectName, title, keywordDict = parseutils.parseLine(line)
     if not title:
         tui.error("Missing title")
         self.do_help(cmd)
         return None
     task = dbutils.addTask(projectName, title, keywordDict)
     if not task:
         tui.reinjectInRawInput(u"%s %s" % (cmd, line))
         return None
     self.lastTaskId = task.id
     return task
示例#8
0
    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)
示例#9
0
 def testExtractKeywords(self):
     for src, dst in gTaskLineToParsedStructList:
         result = parseutils.parseLine(src)
         self.assertEqual(result, dst)