def _create_tar(self, name):
        """Create TAR file."""
        fileobj = utils.create_spooled_temporary_file()
        mode = 'w:gz' if self.compress else 'w'
        tar_file = tarfile.open(name=name, fileobj=fileobj, mode=mode)
        for media_filename in self._explore_storage():
            tarinfo = tarfile.TarInfo(media_filename)
            media_file = self.media_storage.open(media_filename)
            tarinfo.size = len(media_file)
            tar_file.addfile(tarinfo, media_file)
        # Close the TAR for writing
        tar_file.close()
        return fileobj
def _create_tar ( self , name ) : fileobj = utils . create_spooled_temporary_file ( ) mode = 'w:gz' if self . compress else 'w' tar_file = tarfile . open ( name = name , fileobj = fileobj , mode = mode ) for media_filename in self . _explore_storage ( ) : tarinfo = tarfile . TarInfo ( media_filename ) media_file = self . media_storage . open ( media_filename ) tarinfo . size = len ( media_file ) tar_file . addfile ( tarinfo , media_file ) tar_file . close ( ) return fileobj
Create TAR file.