示例#1
0
def import_todo_items(contents):
    new_todos = []
    for t in contents:
        new_todos.append(parse_todo_text(t))
    for t in new_todos:
        smartcontent.process_todo(t)
    datastore.instance.append_todo_list(new_todos)
    return {'imported': len(new_todos)}
示例#2
0
def import_worker(work_q, done_q):
    while True:
        content = work_q.get()
        try:
            todo = parse_todo_text(content)
            smartcontent.process_todo(todo)
            done_q.put(todo)
        except:
            pass
        work_q.task_done()
示例#3
0
def update_todo(_id, values):
    todos = get_todo_list()
    if len(todos) > 0 and len(_id) > 0:
        for t in todos:
            if str(t['id']) == _id:
                for key in values:
                    t[key] = values[key]
                    if key == 'title':
                        smartcontent.process_todo(t)
                todo = t
                break
    if 'update_todo' in datastore.instance.get_features():
        datastore.instance.update_todo(todo)
    else:
        datastore.instance.save_todo_list(todos)
示例#4
0
def save_todo(raw_task, silent=False):
    newtodo = parse_todo_text(raw_task)
    task = newtodo['title']
    tag = newtodo['group']
    if len(task) == 0:
        return

    smartcontent.process_todo(newtodo)
    datastore.instance.save_todo(newtodo)

    if not silent:
        if tag != 'default':
            print ("Added '" + task + "' tagged #" + tag).encode('utf-8')
        else:
            print ("Added '" + task + "'").encode('utf-8')

    config.put(ck.KEY_USER_QUERY_NOITEMPREFIX, '')
    config.update_state(command='add_todo', tag='#'+tag)