コード例 #1
0
def test_project_add_task_str():
    task = Task(1, 'test-task', 'A', str(date.today()))
    project = Project('test-project')
    project.append(task)
    want = '{3}@test-project{1}\n  {0}1: test-task >{2}{1}'.format(
        term.white, term.reset, str(date.today()), term.yellow)
    assert project.get_pretty() == want
コード例 #2
0
ファイル: todo.py プロジェクト: volinthius/dodo
        def add(self, args):
            if len(args) < 1:
                raise TodoError("insufficient arguments")

            # handle project
            if args[0].startswith("@"):
                if len(args) < 2:
                    raise TodoError("insufficient arguments")

                task = self.__find_task_or_project(self.tasks, args[0])

                if task:
                    task.append(Task(self.last_index, " ".join(args[1:])))
                    return True

                else:
                    project = Project(args[0][1:])
                    project.append(Task(self.last_index, " ".join(args[1:])))

                    self.tasks.append(project)
                    self.last_index += 1

                    return True

            # handle task
            else:
                self.tasks.append(Task(self.last_index, " ".join(args)))
                self.last_index += 1

                return True
コード例 #3
0
ファイル: todo.py プロジェクト: antiface/dodo
        def add(self, args):
            if len(args) < 1:
                raise TodoError('insufficient arguments')

            # handle project
            if args[0].startswith('@'):
                if len(args) < 2:
                    raise TodoError('insufficient arguments')

                task = self.__find_task_or_project(self.tasks, args[0])

                if task:
                    task.append(Task(self.last_index, ' '.join(args[1:])))
                    return True

                else:
                    project = Project(args[0][1:])
                    project.append(Task(self.last_index, ' '.join(args[1:])))

                    self.tasks.append(project)
                    self.last_index += 1

                    return True

            # handle task
            else:
                self.tasks.append(Task(self.last_index, ' '.join(args)))
                self.last_index += 1

                return True
コード例 #4
0
def test_project_add_many_task_str():
    task1 = Task(1, 'test-task1', 'A', str(date.today()))
    task2 = Task(2, 'test-task2', 'B', str(date.today()))
    project = Project('test-project')
    project.append(task1)
    project.append(task2)
    want = '{3}@test-project{1}\n  {0}1: test-task1 >{2}{1}\n  {4}2: test-task2 >{2}{1}'.format(
        term.white, term.reset, str(date.today()), term.yellow, term.green)
    print project.get_pretty()
    print want
    assert project.get_pretty() == want
コード例 #5
0
def test_project_add_task_str():
    task = Task(1, 'test-task', 'A', str(date.today()))
    project = Project('test-project')
    project.append(task)
    want = '{3}@test-project{1}\n  {0}1: test-task >{2}{1}'.format(
        term.white,
        term.reset,
        str(date.today()),
        term.yellow
        )
    assert project.get_pretty() == want
コード例 #6
0
def test_project_add_many_task_str():
    task1 = Task(1, 'test-task1', 'A', str(date.today()))
    task2 = Task(2, 'test-task2', 'B', str(date.today()))
    project = Project('test-project')
    project.append(task1)
    project.append(task2)
    want = '{3}@test-project{1}\n  {0}1: test-task1 >{2}{1}\n  {4}2: test-task2 >{2}{1}'.format(
        term.white,
        term.reset,
        str(date.today()),
        term.yellow,
        term.green
        )
    print project.get_pretty()
    print want
    assert project.get_pretty() == want
コード例 #7
0
ファイル: test_project.py プロジェクト: antiface/dodo
def test_sort():
    task0 = Task(0, 'test-desc-0', 'A')
    task1 = Task(0, 'test-desc-1', 'B')
    task2 = Task(0, 'test-desc-2', 'C')

    project = Project('test-project')
    project.append(task2)
    project.append(task1)
    project.append(task0)

    assert project.tasks[0] == task2
    assert project.tasks[1] == task1
    assert project.tasks[2] == task0

    project.sort_tasks()

    assert project.tasks[0] == task0
    assert project.tasks[1] == task1
    assert project.tasks[2] == task2
コード例 #8
0
ファイル: test_project.py プロジェクト: antiface/dodo
def test_sort():
    task0 = Task(0, 'test-desc-0', 'A')
    task1 = Task(0, 'test-desc-1', 'B')
    task2 = Task(0, 'test-desc-2', 'C')

    project = Project('test-project')
    project.append(task2)
    project.append(task1)
    project.append(task0)

    assert project.tasks[0] == task2
    assert project.tasks[1] == task1
    assert project.tasks[2] == task0

    project.sort_tasks()

    assert project.tasks[0] == task0
    assert project.tasks[1] == task1
    assert project.tasks[2] == task2
コード例 #9
0
    def parse(self):
        tasks = []
        index = 0

        with file(self.file_name) as f:
            project = None
            first_line = True

            for line in f.readlines():
                if first_line:
                    first_line = False
                    if not line.startswith('$version 1'):
                        raise ValueError('incorrect version in todo file')

                elif line.strip() == '' or line.startswith('#'):
                    continue

                elif line.startswith('@'):
                    if project: tasks.append(project)
                    project = Project(line[1:].strip())

                else:
                    (pri, dl, done, desc) = line.split(' ', 3)

                    # projectless tasks
                    if not project:
                        index += 1
                        tasks.append(Task(index, desc, pri,
                                          dl if dl != '-' else None,
                                          done if done != '-' else None))

                    # tasks in projects
                    else:
                        index += 1
                        project.append(Task(index, desc, pri,
                                            dl if dl != '-' else None,
                                            done if done != '-' else None))

            if project: tasks.append(project)

        return tasks, index
コード例 #10
0
    def parse(self):
        tasks = []
        index = 0

        with file(self.file_name) as f:
            project = None
            first_line = True

            for line in f.readlines():
                if first_line:
                    first_line = False
                    if not line.startswith('$version 1'):
                        raise ValueError('incorrect version in todo file')

                elif line.strip() == '' or line.startswith('#'):
                    continue

                elif line.startswith('@'):
                    if project: tasks.append(project)
                    project = Project(line[1:].strip())

                else:
                    (pri, dl, done, desc) = line.split(' ', 3)

                    # projectless tasks
                    if not project:
                        index += 1
                        tasks.append(
                            Task(index, desc, pri, dl if dl != '-' else None,
                                 done if done != '-' else None))

                    # tasks in projects
                    else:
                        index += 1
                        project.append(
                            Task(index, desc, pri, dl if dl != '-' else None,
                                 done if done != '-' else None))

            if project: tasks.append(project)

        return tasks, index