def extract_archive(archive_path, destination): """ Extracts given archive into the destination and handle all exceptions. :param archive_path: path to the archive to be extracted :param destination: path to a destination, where the archive should be extracted to :return: """ try: archive = Archive(archive_path) except NotImplementedError as ni_e: raise RebaseHelperError('%s. Supported archives are %s', ni_e.message, Archive.get_supported_archives()) try: archive.extract(destination) except IOError: raise RebaseHelperError("Archive '%s' can not be extracted", archive_path) except (EOFError, SystemError): raise RebaseHelperError("Archive '%s' is damaged", archive_path)
def _extract_sources(self, archive, dir_name): archive = Archive(archive) archive.extract(dir_name)