Exemple #1
0
    def get_todo_from_item(self, group, task):
        todo = {}
        todo['title'] = task.title.content.decode('utf-8')
        todo['done'] = task.title.is_done()
        todo['pinned'] = task.title.has_tag('@pinned')
        todo['due'] = None
        todo['group'] = group.replace(' ', '-').decode('utf-8')
        todo['id'] = task.title._id
        todo['created'] = datetime.now()

        self.get_tag_content(todo, 'due', task, '@due')

        smartcontent_tags = ['@web', '@file', '@app', '@folder']
        tag_actions = {
            '@web': lambda todo, task: self.set_smartcontent(todo, 'Web', task.title.get_tag_param('@web')),
            '@file': lambda todo, task: self.set_smartcontent(todo, 'File', task.title.get_tag_param('@file')),
            '@folder': lambda todo, task: self.set_smartcontent(todo, 'Folder', task.title.get_tag_param('@folder')),
            '@app': lambda todo, task: self.set_smartcontent(todo, 'Application', task.title.get_tag_param('@app'))
        }
        for tag in smartcontent_tags:
            if task.title.has_tag(tag):
                tag_actions[tag](todo, task)

        if todo['due'] and len(todo['due']) > 0:
            due, task = parser.get_due_and_task('@'+todo['due'])
            todo['due'] = due

        return todo