def write_report(project_report, target_dir):
    if os.path.exists(target_dir):
        print('error: cannot create output dir', target_dir)
        exit()
    os.mkdir(target_dir)
    with open(((target_dir + '/') + 'index.html'), 'w') as output_file:
        metrics_formatter.write_project_index(project_report, 'html', output_file)
    for (path, report) in project_report['files'].items():
        write_report_file(report, path, target_dir)
def write_report(project_report, target_dir):
    if os.path.exists(target_dir):
        print('error: cannot create output dir', target_dir)
        exit()
    os.mkdir(target_dir)
    with open(((target_dir + '/') + 'index.html'), 'w') as output_file:
        metrics_formatter.write_project_index(project_report, 'html', output_file)
    for (path, report) in project_report['files'].items():
        write_report_file(report, path, target_dir)