Exemplo n.º 1
0
def lists(order='display', task_counts=False):
	req = api.get('lists')
	lists = req.json()

	if order == 'display':
		positions = list_positions()

		def position(list):
			if list['list_type'] in SMART_LISTS:
				return SMART_LISTS.index(list['list_type'])
			elif list['id'] in positions:
				return positions.index(list['id']) + len(SMART_LISTS)
			else:
				return list['id']

		lists.sort(key=position)

	if task_counts:
		for list in lists:
			update_list_with_tasks_count(list)

	for (index, list) in enumerate(lists):
		if list['list_type'] in SMART_LISTS:
			# List is not capitalized
			list['title'] = list['title'].title()
		list['order'] = index

	return lists
Exemplo n.º 2
0
def list(id, task_counts=False):
    req = api.get('lists/' + id)
    info = req.json()

    # TODO: run this request in parallel
    if task_counts:
        update_list_with_tasks_count(info)

    return info
Exemplo n.º 3
0
def list(id, task_counts=False):
    req = api.get('lists/' + id)
    info = req.json()

    # TODO: run this request in parallel
    if task_counts:
        update_list_with_tasks_count(info)

    return info
def reminders(list_id=None, task_id=None, completed=False):
    data = {'completed': completed}
    if list_id:
        data['list_id'] = int(list_id)
    elif task_id:
        data['task_id'] = int(task_id)
    req = api.get('reminders', data)
    reminders = req.json()

    return reminders
Exemplo n.º 5
0
def reminders(list_id=None, task_id=None, completed=False):
    data = {
        'completed': completed
    }
    if list_id:
        data['list_id'] = int(list_id)
    elif task_id:
        data['task_id'] = int(task_id)
    req = api.get('reminders', data)
    reminders = req.json()

    return reminders
Exemplo n.º 6
0
def tasks(list_id, completed=False, subtasks=False, positions=None):
    start = time.time()
    req = api.get(('subtasks' if subtasks else 'tasks'), {
        'list_id': int(list_id),
        'completed': completed
    })
    tasks = []
    positions = []
    task_type = ''

    if completed:
        task_type += 'completed '
    if subtasks:
        task_type += 'sub'

    tasks = req.json()
    log.info('Retrieved %stasks for list %d in %s', task_type, list_id, time.time() - start)

    return tasks
Exemplo n.º 7
0
def lists(order='display', task_counts=False):
    start = time.time()
    req = api.get('lists')
    lists = []
    positions = []

    if order == 'display':
        with futures.ThreadPoolExecutor(max_workers=2) as executor:

            def get_tasks():
                lists.extend(req.json())

            def get_positions():
                positions.extend(task_positions(list_id))

            executor.submit(get_tasks)
            executor.submit(get_positions)

        def position(list):
            if list['list_type'] in SMART_LISTS:
                return SMART_LISTS.index(list['list_type'])
            elif list['id'] in positions:
                return positions.index(list['id']) + len(SMART_LISTS)
            else:
                return list['id']

        log.info('Retrieved lists and positions in %s', time.time() - start)
        lists.sort(key=position)
    else:
        lists = req.json()
        log.info('Retrieved lists in %s', time.time() - start)

    if task_counts:
        for list in lists:
            update_list_with_tasks_count(list)

    for (index, list) in enumerate(lists):
        if list['list_type'] in SMART_LISTS:
            # List is not capitalized
            list[u'title'] = list['title'].title()
        list[u'order'] = index

    return lists
Exemplo n.º 8
0
def tasks(list_id, completed=False, subtasks=False, positions=None):
    start = time.time()
    req = api.get(('subtasks' if subtasks else 'tasks'), {
        'list_id': int(list_id),
        'completed': completed
    })
    tasks = []
    positions = []
    task_type = ''

    if completed:
        task_type += 'completed '
    if subtasks:
        task_type += 'sub'

    tasks = req.json()
    log.info('Retrieved %stasks for list %d in %s', task_type, list_id, time.time() - start)

    return tasks
Exemplo n.º 9
0
def lists(order='display', task_counts=False):
    start = time.time()
    req = api.get('lists')
    lists = []
    positions = []

    if order == 'display':
        with futures.ThreadPoolExecutor(max_workers=2) as executor:
            def get_tasks():
                lists.extend(req.json())

            def get_positions():
                positions.extend(task_positions(list_id))

            executor.submit(get_tasks)
            executor.submit(get_positions)

        def position(list):
            if list['list_type'] in SMART_LISTS:
                return SMART_LISTS.index(list['list_type'])
            elif list['id'] in positions:
                return positions.index(list['id']) + len(SMART_LISTS)
            else:
                return list['id']

        log.info('Retrieved lists and positions in %s', time.time() - start)
        lists.sort(key=position)
    else:
        lists = req.json()
        log.info('Retrieved lists in %s', time.time() - start)

    if task_counts:
        for list in lists:
            update_list_with_tasks_count(list)

    for (index, list) in enumerate(lists):
        if list['list_type'] in SMART_LISTS:
            # List is not capitalized
            list[u'title'] = list['title'].title()
        list[u'order'] = index

    return lists
Exemplo n.º 10
0
def list_tasks_count(id):
    req = api.get('lists/tasks_count', {'list_id': id})
    info = req.json()

    return info
Exemplo n.º 11
0
def root():
    req = api.get('root')
    info = req.json()

    return info
Exemplo n.º 12
0
def list_positions():
    req = api.get('list_positions')
    info = req.json()

    return info[0]['values']
Exemplo n.º 13
0
def user():
	req = api.get('user')
	user = req.json()

	return user
Exemplo n.º 14
0
def task(id):
    req = api.get('tasks/%d' % int(id))
    info = req.json()

    return info
Exemplo n.º 15
0
def reminder(id):
    req = api.get('reminders/' + id)
    info = req.json()

    return info
Exemplo n.º 16
0
def user():
    req = api.get('user')
    user = req.json()

    return user
Exemplo n.º 17
0
def list_tasks_count(id):
    req = api.get('lists/tasks_count', {'list_id': id})
    info = req.json()

    return info
Exemplo n.º 18
0
def task(id):
    req = api.get('tasks/%d' % int(id))
    info = req.json()

    return info
Exemplo n.º 19
0
def list_positions():
    req = api.get('list_positions')
    info = req.json()

    return info[0]['values']
Exemplo n.º 20
0
def settings():
    req = api.get('settings')
    settings = req.json()

    return settings
Exemplo n.º 21
0
def root():
	req = api.get('root')
	info = req.json()

	return info
Exemplo n.º 22
0
def settings():
	req = api.get('settings')
	settings = req.json()

	return settings
def reminder(id):
    req = api.get('reminders/' + id)
    info = req.json()

    return info