import bz2
import shutil


def bz2_unzip(zipped_path, unzipped_path):
    
    """Unzips downloaded bz2 compressed file."""

    with bz2.open(zipped_path.resolve().as_posix()) as zipped:
        print(f"Unzipping [{zipped_path.resolve().as_posix()}] as [{unzipped_path.resolve().as_posix()}]")
        with unzipped_path.open(mode='wb') as unzipped:
            shutil.copyfileobj(zipped, unzipped)
        print("Unzipped.")
    
    return unzipped