code: def generate(self):
          
          if self._tar_buffer.tell():
              self._tar_buffer.seek(0, 0)
              yield self._tar_buffer.read()
  
          for fname in self._files_to_add:
              last = self._tar_buffer.tell()
              self._tar_obj.add(fname)
              self._tar_buffer.seek(last, os.SEEK_SET)
              data = self._tar_buffer.read()
              yield data
  
          for info, content in self._ios_to_add.items():
              last = self._tar_buffer.tell()
              self._tar_obj.addfile(info, content)
              self._tar_buffer.seek(last, os.SEEK_SET)
              data = self._tar_buffer.read()
              yield data
  
          self._tar_obj.close()
          yield self._tar_buffer.read()
          self._generated = True
docs: generate tar file
  
          ..Usage::
  
              >>> tarfile = b"".join(data for data in tg.generate())