def _create_urllib_reporthook(progress_bar):
    """Create a urllib reporthook for updating a progress bar.

    Args:
        progress_bar (tqdm): A progress bar instance.

    Returns:
        A urllib progress callback function.
    """
    def update_progress(count, block_size, total_size):
        progress_bar.total = total_size
        n_bytes_received = count * block_size
        progress_bar.update(n_bytes_received - progress_bar.n)
    return update_progress