(filename, extract_dir=None, format=None)
Unpack an archive.

    `filename` is the name of the archive.

    `extract_dir` is the name of the target directory, where the archive
    is unpacked. If not provided, the current working directory is used.

    `format` is the archive format: one of "zip", "tar", "gztar", "bztar",
    or "xztar".  Or any other registered format.  If not provided,
    unpack_archive will use the filename extension and see if an unpacker
    was registered for that extension.

    In case none is found, a ValueError is raised.
Unpack an archive.
Unpack an archive .
def unpack_archive(filename, extract_dir=None, format=None):
    """Unpack an archive.

    `filename` is the name of the archive.

    `extract_dir` is the name of the target directory, where the archive
    is unpacked. If not provided, the current working directory is used.

    `format` is the archive format: one of "zip", "tar", "gztar", "bztar",
    or "xztar".  Or any other registered format.  If not provided,
    unpack_archive will use the filename extension and see if an unpacker
    was registered for that extension.

    In case none is found, a ValueError is raised.
    """
    sys.audit("shutil.unpack_archive", filename, extract_dir, format)

    if extract_dir is None:
        extract_dir = os.getcwd()

    extract_dir = os.fspath(extract_dir)
    filename = os.fspath(filename)

    if format is not None:
        try:
            format_info = _UNPACK_FORMATS[format]
        except KeyError:
            raise ValueError("Unknown unpack format '{0}'".format(format)) from None

        func = format_info[1]
        func(filename, extract_dir, **dict(format_info[2]))
    else:
        # we need to look at the registered unpackers supported extensions
        format = _find_unpack_format(filename)
        if format is None:
            raise ReadError("Unknown archive format '{0}'".format(filename))

        func = _UNPACK_FORMATS[format][1]
        kwargs = dict(_UNPACK_FORMATS[format][2])
        func(filename, extract_dir, **kwargs)
def unpack_archive ( filename , extract_dir = None , format = None ) : sys . audit ( "shutil.unpack_archive" , filename , extract_dir , format ) if extract_dir is None : extract_dir = os . getcwd ( ) extract_dir = os . fspath ( extract_dir ) filename = os . fspath ( filename ) if format is not None : try : format_info = _UNPACK_FORMATS [ format ] except KeyError : raise ValueError ( "Unknown unpack format '{0}'" . format ( format ) ) from None func = format_info [ 1 ] func ( filename , extract_dir , * * dict ( format_info [ 2 ] ) ) else : # we need to look at the registered unpackers supported extensions format = _find_unpack_format ( filename ) if format is None : raise ReadError ( "Unknown archive format '{0}'" . format ( filename ) ) func = _UNPACK_FORMATS [ format ] [ 1 ] kwargs = dict ( _UNPACK_FORMATS [ format ] [ 2 ] ) func ( filename , extract_dir , * * kwargs )