def export_tasks(task_id, path, batch, closed):
    """
    :type task_id: vulyk.models.task_types.AbstractTaskType
    :type path: str | unicode
    :type batch: str | unicode
    :type closed: boolean
    """
    i = 0

    try:
        with open(path, 'w+') as f:
            for report in task_id.export_reports(batch, closed):
                f.write(json.dumps(report) + os.linesep)
                i += 1

                if i + 1 % 100 == 0:
                    echo('{0:d} tasks processed'.format(i))
    except ValueError as e:
        echo('Error while encoding json in {0}: {1}'.format(path, e))
    except __HOLE__ as e:
        echo('Got IO error when tried to decode {0}: {1}'.format(path, e))

    echo('Finished exporting answers for {0:d} tasks'.format(i))
dataset/ETHPy150Open mrgambal/vulyk/vulyk/cli/db.py/export_tasks