コード例 #1
0
ファイル: taskcmd.py プロジェクト: semtle/yokadi
    def do_t_describe(self, line):
        """Starts an editor to enter a longer description of a task.
        t_describe <id>"""
        def updateDescription(description):
            if self.cryptoMgr.isEncrypted(task.title):
                task.description = self.cryptoMgr.encrypt(description)
            else:
                task.description = description

        task = self.getTaskFromId(line)
        try:
            if self.cryptoMgr.isEncrypted(task.title):
                # As title is encrypted, we assume description will be encrypted as well
                self.cryptoMgr.force_decrypt = True  # Decryption must be turned on to edit

            description = tui.editText(
                self.cryptoMgr.decrypt(task.description),
                onChanged=updateDescription,
                lockManager=dbutils.TaskLockManager(task),
                prefix="yokadi-%s-%s-" % (task.project, task.title))
        except Exception as e:
            raise YokadiException(e)
        updateDescription(description)
        self.session.merge(task)
        self.session.commit()
コード例 #2
0
ファイル: taskcmd.py プロジェクト: fabaff/yokadi
    def do_t_reorder(self, line):
        """Reorder tasks of a project.
        It works by starting an editor with the task list: you can then change
        the order of the lines and save the list. The urgency field will be
        updated to match the order.
        t_reorder <project_name>"""
        try:
            project = self.session.query(Project).filter_by(name=line).one()
        except (MultipleResultsFound, NoResultFound):
            raise BadUsageException("You must provide a valid project name")

        taskList = self.session.query(Task).filter(Task.projectId == project.id,
                                                   Task.status != 'done').order_by(desc(Task.urgency))
        lines = ["%d,%s" % (x.id, x.title) for x in taskList]
        text = tui.editText("\n".join(lines))

        ids = []
        for line in text.split("\n"):
            line = line.strip()
            if not "," in line:
                continue
            ids.append(int(line.split(",")[0]))

        ids.reverse()
        for urgency, taskId in enumerate(ids):
            task = self.session.query(Task).get(taskId)
            task.urgency = urgency
            self.session.merge(task)
        self.session.commit()
コード例 #3
0
ファイル: taskcmd.py プロジェクト: bport/yokadi
    def do_t_reorder(self, line):
        """Reorder tasks of a project.
        It works by starting an editor with the task list: you can then change
        the order of the lines and save the list. The urgency field will be
        updated to match the order.
        t_reorder <project_name>"""
        try:
            project = Project.byName(line)
        except SQLObjectNotFound:
            raise BadUsageException("You must provide a valid project name")

        taskList = Task.select(AND(Task.q.projectID == project.id,
                                   Task.q.status != 'done'),
                               orderBy=-Task.q.urgency)
        lines = ["%d,%s" % (x.id, x.title) for x in taskList]
        text = tui.editText("\n".join(lines))

        ids = []
        for line in text.split("\n"):
            line = line.strip()
            if not "," in line:
                continue
            id = int(line.split(",")[0])
            ids.append(id)

        ids.reverse()
        for urgency, id in enumerate(ids):
            task = Task.get(id)
            task.urgency = urgency
コード例 #4
0
ファイル: taskcmd.py プロジェクト: semtle/yokadi
    def do_t_reorder(self, line):
        """Reorder tasks of a project.
        It works by starting an editor with the task list: you can then change
        the order of the lines and save the list. The urgency field will be
        updated to match the order.
        t_reorder <project_name>"""
        try:
            project = self.session.query(Project).filter_by(name=line).one()
        except (MultipleResultsFound, NoResultFound):
            raise BadUsageException("You must provide a valid project name")

        taskList = self.session.query(Task).filter(
            Task.projectId == project.id,
            Task.status != 'done').order_by(desc(Task.urgency))
        lines = ["%d,%s" % (x.id, x.title) for x in taskList]
        text = tui.editText("\n".join(lines))

        ids = []
        for line in text.split("\n"):
            line = line.strip()
            if not "," in line:
                continue
            ids.append(int(line.split(",")[0]))

        ids.reverse()
        for urgency, taskId in enumerate(ids):
            task = self.session.query(Task).get(taskId)
            task.urgency = urgency
            self.session.merge(task)
        self.session.commit()
コード例 #5
0
ファイル: taskcmd.py プロジェクト: bport/yokadi
    def do_t_reorder(self, line):
        """Reorder tasks of a project.
        It works by starting an editor with the task list: you can then change
        the order of the lines and save the list. The urgency field will be
        updated to match the order.
        t_reorder <project_name>"""
        try:
            project = Project.byName(line)
        except SQLObjectNotFound:
            raise BadUsageException("You must provide a valid project name")

        taskList = Task.select(AND(Task.q.projectID == project.id,
                                   Task.q.status != 'done'),
                               orderBy=-Task.q.urgency)
        lines = ["%d,%s" % (x.id, x.title) for x in taskList]
        text = tui.editText("\n".join(lines))

        ids = []
        for line in text.split("\n"):
            line = line.strip()
            if not "," in line:
                continue
            id = int(line.split(",")[0])
            ids.append(id)

        ids.reverse()
        for urgency, id in enumerate(ids):
            task = Task.get(id)
            task.urgency = urgency
コード例 #6
0
ファイル: taskcmd.py プロジェクト: semtle/yokadi
    def do_t_medit(self, line):
        """Mass edit tasks of a project.
        t_medit <project_name>

        Starts a text editor with the task list, you can then:
        - edit tasks text and keywords
        - mark tasks as done or started
        - add new tasks
        - adjust urgency
        - delete tasks
        """
        if not line:
            raise BadUsageException("Missing parameters")
        projectName = parseutils.parseOneWordName(line)
        projectName = self._realProjectName(projectName)
        project = dbutils.getOrCreateProject(projectName)
        if not project:
            return

        oldList = massedit.createEntriesForProject(project)
        oldText = massedit.createMEditText(oldList)
        newText = oldText
        while True:
            newText = tui.editText(newText, suffix=".medit")
            if newText == oldText:
                print("No changes")
                return

            try:
                newList = massedit.parseMEditText(newText)
            except massedit.ParseError as exc:
                print(exc)
                print()
                if tui.confirm("Modify text and try again"):
                    lst = newText.splitlines()
                    lst.insert(exc.lineNumber, "# ^ " + exc.message)
                    newText = "\n".join(lst)
                    continue
                else:
                    return

            try:
                massedit.applyChanges(project, oldList, newList)
                self.session.commit()
                break
            except YokadiException as exc:
                print(exc)
                print()
                if not tui.confirm("Modify text and try again"):
                    return
コード例 #7
0
ファイル: taskcmd.py プロジェクト: agateau/yokadi
    def do_t_medit(self, line):
        """Mass edit tasks of a project.
        t_medit <project_name>

        Starts a text editor with the task list, you can then:
        - edit tasks text and keywords
        - mark tasks as done or started
        - add new tasks
        - adjust urgency
        - delete tasks
        """
        if not line:
            raise BadUsageException("Missing parameters")
        projectName = parseOneWordName(line)
        projectName = self._realProjectName(projectName)
        project = dbutils.getOrCreateProject(projectName)
        if not project:
            return

        oldList = massedit.createEntriesForProject(project)
        oldText = massedit.createMEditText(oldList)
        newText = oldText
        while True:
            newText = tui.editText(newText, suffix=".medit")
            if newText == oldText:
                print("No changes")
                return

            try:
                newList = massedit.parseMEditText(newText)
            except massedit.ParseError as exc:
                print(exc)
                print()
                if tui.confirm("Modify text and try again"):
                    lst = newText.splitlines()
                    lst.insert(exc.lineNumber, "# ^ " + exc.message)
                    newText = "\n".join(lst)
                    continue
                else:
                    return

            try:
                massedit.applyChanges(project, oldList, newList)
                self.session.commit()
                break
            except YokadiException as exc:
                print(exc)
                print()
                if not tui.confirm("Modify text and try again"):
                    return
コード例 #8
0
ファイル: taskcmd.py プロジェクト: agateau/yokadi
    def do_t_describe(self, line):
        """Starts an editor to enter a longer description of a task.
        t_describe <id>"""
        def updateDescription(description):
            task.description = description

        task = self.getTaskFromId(line)
        try:
            description = tui.editText(task.description,
                                       onChanged=updateDescription,
                                       lockManager=dbutils.TaskLockManager(task),
                                       prefix="yokadi-%s-%s-" % (task.project, task.title))
        except Exception as e:
            raise YokadiException(e)
        updateDescription(description)
        self.session.merge(task)
        self.session.commit()
コード例 #9
0
ファイル: taskcmd.py プロジェクト: bport/yokadi
    def do_t_describe(self, line):
        """Starts an editor to enter a longer description of a task.
        t_describe <id>"""
        def updateDescription(description):
            if self.cryptoMgr.isEncrypted(task.title):
                task.description = self.cryptoMgr.encrypt(description)
            else:
                task.description = description

        task = self.getTaskFromId(line)
        try:
            if self.cryptoMgr.isEncrypted(task.title):
                # As title is encrypted, we assume description will be encrypted as well
                self.cryptoMgr.force_decrypt = True  # Decryption must be turned on to edit

            description = tui.editText(self.cryptoMgr.decrypt(task.description),
                                       onChanged=updateDescription,
                                       lockManager=dbutils.TaskLockManager(task),
                                       prefix=u"yokadi-%s-%s-" % (task.project, task.title))
        except Exception, e:
            raise YokadiException(e)
コード例 #10
0
ファイル: tuitestcase.py プロジェクト: agateau/yokadi
 def testEditEmptyText(self):
     os.environ["EDITOR"] = "/bin/true"
     out = tui.editText(None)
     self.assertEqual(out, "")
コード例 #11
0
 def testEditEmptyText(self):
     os.environ["EDITOR"] = "/bin/true"
     out = tui.editText(None)
     self.assertEqual(out, "")