def tasks_by_proj(args):
    hv = get_harvest()
    if hv:
        projects = get_projects(hv, args.projectids)
        if len(projects) > 0:
            times = parse_time_inputs(args.start, args.end)
            start = times[0]
            end = times[1]
            tasks_by_id = {task.id: task for task in hv.tasks()}
            print str.format(
                REPORT_HEADER,
                'Tasks By Project',
                start.strftime('%Y-%m-%d'),
                end.strftime('%Y-%m-%d'),
            )
            for project in projects:
                print str.format(
                    PROJECT_BY_TASKS_HEADER_FORMAT,
                    project = project
                )
                entries = project.entries(start = start, end = end)
                project_tasks = {}
                for entry in entries:
                    task = tasks_by_id[entry.task_id]
                    if project_tasks.has_key(task):
                        project_tasks[task] += entry.hours
                    else:
                        project_tasks[task] = entry.hours
                for task in project_tasks:
                    print str.format(
                        TASKS_BODY_FORMAT,
                        name = task.name,
                        hours = project_tasks[task]
                    )
        else:
            print 'No such project ID(s).'
dataset/ETHPy150Open jakebasile/reap/reap/commands/reports.py/tasks_by_proj/original