예제 #1
0
파일: taskcmd.py 프로젝트: ryanakca/yokadi
    def do_t_add_keywords(self, line):
        """Add keywords to an existing task
        t_add_keyword <id> <keyword1> <keyword2>[=<value>]...
        """
        tokens = line.split(" ", 1)
        if len(tokens) < 2:
            raise YokadiException("You should give at least two arguments: <task id> <keyword>")
        task = dbutils.getTaskFromId(tokens[0])
        remainingText, newKwDict = parseutils.extractKeywords(tokens[1])

        dbutils.createMissingKeywords(newKwDict.keys())

        kwDict = task.getKeywordDict()
        kwDict.update(newKwDict)
        task.setKeywordDict(kwDict)
예제 #2
0
파일: taskcmd.py 프로젝트: mathstuf/yokadi
    def do_t_add_keywords(self, line):
        """Add keywords to an existing task
        t_add_keyword <id> <@keyword1> <@keyword2>[=<value>]...
        """
        tokens = parseutils.simplifySpaces(line).split(" ", 1)
        if len(tokens) < 2:
            raise YokadiException("You should give at least two arguments: <task id> <keyword>")
        task = dbutils.getTaskFromId(tokens[0])
        garbage, keywordFilters = parseutils.extractKeywords(tokens[1])
        newKwDict = parseutils.keywordFiltersToDict(keywordFilters)
        if garbage:
            raise YokadiException("Cannot parse line, got garbage (%s). Maybe you forgot to add @ before keyword ?"
                                   % garbage)

        dbutils.createMissingKeywords(newKwDict.keys())

        kwDict = task.getKeywordDict()
        kwDict.update(newKwDict)
        task.setKeywordDict(kwDict)
예제 #3
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)
예제 #4
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)