コード例 #1
0
    def new_task(self):
        """
        Create a new empty task

        :return: a empty task
        :rtype: Taskwarrior task object
        """
        return Task(self.taskwarrior_client)
コード例 #2
0
ファイル: vwtask.py プロジェクト: gitter-badger/taskwiki
    def task(self):
        # New task object accessed second or later time
        if self.__unsaved_task is not None:
            return self.__unsaved_task

        # Return the corresponding task if alrady set
        # Else try to load it or create a new one
        if self.uuid:
            try:
                return self.cache[self.uuid]
            except Task.DoesNotExist:
                # Task with stale uuid, recreate
                self.__unsaved_task = Task(self.tw)
                # If task cannot be loaded, we need to remove the UUID
                vim.command('echom "UUID not found: %s,'
                            'will be replaced if saved"' % self.uuid)
                self.uuid = None
        else:
            # New task object accessed first time
            self.__unsaved_task = Task(self.tw)

        return self.__unsaved_task
コード例 #3
0
 def test_add(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         assert len(tw.tasks.filter('Arena:foo')) == 1
コード例 #4
0
 def test_local(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         result = self.runner.invoke(cli, cmd + ['local', 'foo', 'dishes'])
         assert 'dishes' in result.output
コード例 #5
0
 def test_remote(self):
     with self.runner.isolated_filesystem():
         self.runner.invoke(cli, cmd_dummy_arena)
         dloc = os.getcwd() + '/remote'
         tw = TaskWarrior(dloc)
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t['Arena'] = 'foo'
         t['ArenaTaskID'] = '1'
         t.save()
         result = self.runner.invoke(cli, cmd + ['remote', 'foo', 'dishes'])
         assert 'dishes' in result.output
コード例 #6
0
ファイル: base.py プロジェクト: gitter-badger/taskwiki
    def generate_data(self):
        super(MultipleSourceTest, self).generate_data()

        self.extra_dir = tempfile.mkdtemp(dir='/tmp/')

        self.extra_tw = TaskWarrior(
            data_location=self.extra_dir,
            taskrc_location='/'
        )

        extra_tasks = [Task(self.extra_tw, **task_kwargs)
                      for task_kwargs in self.extra_tasks]

        self.extra_tasks = extra_tasks
        for task in self.extra_tasks:
            task.save()
コード例 #7
0
 def test_sync(self):
     with self.runner.isolated_filesystem():
         cwd = os.getcwd()
         dloc = cwd + '/local'
         dremote = cwd + '/remote'
         tw_local = TaskWarrior(dloc)
         tw_remote = TaskWarrior(dremote)
         t = Task(tw_local)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         result = self.runner.invoke(cli,
                                     cmd + ['sync', 'foo'],
                                     input='a\n')
         assert len(tw_remote.tasks.filter()) == 1
コード例 #8
0
ファイル: base.py プロジェクト: gitter-badger/taskwiki
    def generate_data(self):
        self.dir = tempfile.mkdtemp(dir='/tmp/')

        # Create an actual taskrc file where we can write later
        self.taskrc_path = os.path.join(self.dir, "taskrc")
        with open(self.taskrc_path, 'w') as f:
            f.write("#testing taskrc\n")

        self.tw = TaskWarrior(
            data_location=self.dir,
            taskrc_location=self.taskrc_path
        )

        new_tasks = [Task(self.tw, **task_kwargs)
                     for task_kwargs in self.tasks]

        self.tasks = new_tasks
        for task in self.tasks:
            task.save()
コード例 #9
0
def download_trello_card(project_name, list_name, trello_card, task_warrior,
                         doing_list_name, done_list_name):
    """
    Download all contens of trello card creating new Task Warrior task

    :project_name: the name of project where the card is stored
    :list_name: the name of list where the card is stored
    :trello_card: a Trello Card object
    :task_warrior: Task Warrior object
    :doing_list_name: name of doing list to set task active
    :done_list_name: name of done list to set task done
    """
    new_tw_task = Task(task_warrior)
    new_tw_task['project'] = project_name
    new_tw_task['description'] = trello_card.name
    if trello_card.due_date:
        new_tw_task['due'] = trello_card.due_date
    new_tw_task['trelloid'] = trello_card.id
    new_tw_task['trellolistname'] = list_name
    new_tw_task.save()
    if list_name == doing_list_name:
        new_tw_task.start()
    if list_name == done_list_name:
        new_tw_task.done()