human
I wrote the below code

    if (not os.path.exists(whoosh_index_dir)):
        os.makedirs(whoosh_index_dir)
    tool_index_dir = os.path.join(whoosh_index_dir, 'tools')
    if (not os.path.exists(tool_index_dir)):
        os.makedirs(tool_index_dir)
    repo_index_storage = FileStorage(whoosh_index_dir)
    tool_index_storage = FileStorage(tool_index_dir)
    repo_index = repo_index_storage.create_index(repo_schema)
    tool_index = tool_index_storage.create_index(tool_schema)
    repo_index_writer = repo_index.writer()
    tool_index_writer = tool_index.writer()
    def to_unicode(a_basestr):
        if (type(a_basestr) is str):
            return unicode(a_basestr, 'utf-8')
        else:
            return a_basestr
    repos_indexed = 0
    tools_indexed = 0
    for repo in get_repos(sa_session, path_to_repositories):
        repo_index_writer.add_document(id=repo.get('id'), name=to_unicode(repo.get('name')), description=to_unicode(repo.get('description')), long_description=to_unicode(repo.get('long_description')), homepage_url=to_unicode(repo.get('homepage_url')), remote_repository_url=to_unicode(repo.get('remote_repository_url')), repo_owner_username=to_unicode(repo.get('repo_owner_username')), times_downloaded=repo.get('times_downloaded'), approved=repo.get('approved'), last_updated=repo.get('last_updated'), full_last_updated=repo.get('full_last_updated'))
        for tool in repo.get('tools_list'):
            tool_index_writer.add_document(id=to_unicode(tool.get('id')), name=to_unicode(tool.get('name')), version=to_unicode(tool.get('version')), description=to_unicode(tool.get('description')), help=to_unicode(tool.get('help')), repo_owner_username=to_unicode(repo.get('repo_owner_username')), repo_name=to_unicode(repo.get('name')), repo_id=repo.get('id'))
            tools_indexed += 1
            print tools_indexed, 'tools    (', tool.get('id'), ')'
        repos_indexed += 1
        print repos_indexed, 'repos    (', repo.get('id'), ')'
    tool_index_writer.commit()
    repo_index_writer.commit()
    print 'TOTAL    repos...

What's a good function header?
assistant
#Here is Python code to print tools_indexed, 'tools    (', tool.

def build_index(sa_session, whoosh_index_dir, path_to_repositories):