import tempfile
import zipfile


def decompress(zip_file, dir=None):
    """Decompress Zip file

    Decompress any zip file. For example, TOSCA CSAR

    inputs:
       zip_file: file in zip format
       dir: directory to decompress zip. If not provided an unique temporary
            directory will be generated and used.
    return:
       dir: absolute path to the decopressed directory
    """
    if not dir:
        dir = tempfile.NamedTemporaryFile().name
    with zipfile.ZipFile(zip_file, "r") as zf:
        zf.extractall(dir)
    return dir