def _import_to_diffscuss(gh, username, password, user_or_org, repo,
                         pull_request, output_dir):
    logging.info("Getting diff text for pull request %s", pull_request.url)
    diff_text = _get_diff_text(username, password, pull_request)
    composer = DiffscussComposer(diff_text)
    _overlay_encoding(composer)
    _overlay_pr_top_level(composer, gh, pull_request)
    _overlay_pr_comments(composer, pull_request)
    _overlay_commit_comments(composer, pull_request)

    dest_dir = os.path.join(output_dir, user_or_org.login, repo.name)
    logging.debug("Destination dir is %s", dest_dir)
    _mkdir_p(dest_dir)
    dest_fname = os.path.join(dest_dir, u"%s.diffscuss" % pull_request.number)
    logging.debug("Destination filename is %s", dest_fname)
    dest_fname_partial = u"%s.partial" % dest_fname
    logging.debug("Writing partial results to %s", dest_fname_partial)

    with open(dest_fname_partial, 'wb') as dest_fil:
        for line in composer.render():
            dest_fil.write(line.encode('utf-8'))

    logging.info("Moving final results to %s", dest_fname)
    shutil.move(dest_fname_partial, dest_fname)
dataset/ETHPy150Open hut8labs/diffscuss/diffscuss/github_import.py/_import_to_diffscuss/original