예제 #1
0
파일: lists.py 프로젝트: Alfr0475/alfred.d
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
예제 #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
예제 #3
0
파일: lists.py 프로젝트: amatiasq/dotfiles
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
예제 #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
예제 #6
0
파일: tasks.py 프로젝트: amatiasq/dotfiles
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
예제 #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
예제 #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
예제 #9
0
파일: lists.py 프로젝트: amatiasq/dotfiles
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
예제 #10
0
def list_tasks_count(id):
    req = api.get('lists/tasks_count', {'list_id': id})
    info = req.json()

    return info
예제 #11
0
def root():
    req = api.get('root')
    info = req.json()

    return info
예제 #12
0
def list_positions():
    req = api.get('list_positions')
    info = req.json()

    return info[0]['values']
예제 #13
0
파일: user.py 프로젝트: Alfr0475/alfred.d
def user():
	req = api.get('user')
	user = req.json()

	return user
예제 #14
0
def task(id):
    req = api.get('tasks/%d' % int(id))
    info = req.json()

    return info
예제 #15
0
def reminder(id):
    req = api.get('reminders/' + id)
    info = req.json()

    return info
예제 #16
0
def user():
    req = api.get('user')
    user = req.json()

    return user
예제 #17
0
파일: lists.py 프로젝트: amatiasq/dotfiles
def list_tasks_count(id):
    req = api.get('lists/tasks_count', {'list_id': id})
    info = req.json()

    return info
예제 #18
0
파일: tasks.py 프로젝트: amatiasq/dotfiles
def task(id):
    req = api.get('tasks/%d' % int(id))
    info = req.json()

    return info
예제 #19
0
파일: lists.py 프로젝트: amatiasq/dotfiles
def list_positions():
    req = api.get('list_positions')
    info = req.json()

    return info[0]['values']
예제 #20
0
def settings():
    req = api.get('settings')
    settings = req.json()

    return settings
예제 #21
0
파일: root.py 프로젝트: Alfr0475/alfred.d
def root():
	req = api.get('root')
	info = req.json()

	return info
예제 #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